I am using SendOnlyBus with NserviceBus 5.2
and my set-up code is like
busConfiguration.UsePersistence<NHibernatePersistence,StorageType.Subscriptions>();
busConfiguration.AssembliesToScan(AssembliesToScan);
busConfiguration.UseTransport<MsmqTransport>();
busConfiguration.PurgeOnStartup(false);
busConfiguration.UseSerialization<XmlSerializer>();
return Bus.CreateSendOnly(busConfiguration);
and web.config
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MsmqTransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" />
<MsmqTransportConfig InputQueue="XXX" ErrorQueue="XXX" NumberOfWorkerThreads="X" MaxRetries="X" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="X" Endpoint="X" />
</MessageEndpointMappings>
</UnicastBusConfig>
<add name="NServiceBus/Persistence" connectionString="Data Source=XXX;database=XXX;User ID=XX;Password=XXx;" />
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
this leads to error while publishing message.
Cannot publish on this endpoint - no subscription storage has been
configured."
If i use Memory Persistence, it works fine but not with Hibernate
DB-Subscription, Not able to find out what's missing or wrong.
Appreciate any help ?.
Thanks
Explanation
NServiceBus is not configuring subscription persistence because you have asked for a send only endpoint.
Send only endpoints do not have an input queue, which means they have no way to receive and store subscriptions. Trying to Publish makes no sense if you have no subscribers.
Either
keep the send only bus, but switch from using Bus.Publish() to Bus.Send()
or
use a complete bus by calling return Bus.Create(busConfiguration) instead of return Bus.CreateSendOnly(busConfiguration)
Code sample
The only code needed to publish an event with NHibernate as subscription persistence on NServiceBus 5.2.0 and NServiceBus.NHibernate 6.1.2 is the following:
Program.cs
using System;
using NServiceBus;
using NServiceBus.Features;
using NServiceBus.Persistence;
class Program
{
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.DisableFeature<TimeoutManager>();
busConfiguration.UsePersistence<NHibernatePersistence, StorageType.Subscriptions>();
using (IStartableBus bus = Bus.Create(busConfiguration))
{
bus.Start();
bus.Publish(new SomeEvent());
Console.WriteLine("Published an event");
Console.ReadLine();
}
}
class SomeEvent : IEvent {}
}
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NServiceBus/Persistence" connectionString="Data Source=.;database=database;User ID=user;Password=password;"/>
</connectionStrings>
<appSettings>
<add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2012Dialect" />
</appSettings>
</configuration>
Related
I'm having issues trying to log in to a CRM Online organization through the use of the latest version of the Xrm Tooling nuget package using the connection string constructor from a custom powershell cmdlet.
I'm receiving a rather unhelpful "Unable to Login to Dynamics CRM" error message and am attempting to enable tracing to troubleshoot but have not been able to enable it by modifying the .dll.config file like the below (taken from an XrmToolbox issue on GitHub):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchName="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
<source name="Microsoft.Xrm.Tooling.CrmConnectControl"
switchName="Microsoft.Xrm.Tooling.CrmConnectControl"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
</sources>
<switches>
<!--
Possible values for switches: Off, Error, Warning, Info, Verbose
Verbose: includes Error, Warning, Info, Trace levels
Info: includes Error, Warning, Info levels
Warning: includes Error, Warning levels
Error: includes Error level
-->
<add name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.CrmConnectControl" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.WebResourceUtility" value="Verbose" />
</switches>
<sharedListeners>
<add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="XRMToolingLogs.log" />
<!--<add name="eventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="XRMTooling" />-->
</sharedListeners>
</system.diagnostics>
</configuration>
I was able to work around this by configuring the listener programmatically through:
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.TraceLevel = System.Diagnostics.SourceLevels.All;
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.AddTraceListener(new TextWriterTraceListener("log.txt"));
Which pointed me to the actual error which was that the CrmServiceClient was expecting a URL with the organization unique name instead of the URL name.
Trying to get quartz to log in ms sql server but getting error in web config file.
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="SchedulingPOC"/>
<add key="quartz.scheduler.instanceId" value="SchedulingPOC"/>
<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<!-- Configure Job Store -->
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.useProperties" value="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.dataSource.default.connectionString" value="Server=.\SQLExpress;Database=testDB;Trusted_Connection=True;"/>
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
</quartz>
Running the application in debug mode of Visual Studio Express for web.
Error message:
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070032
Config Error The configuration section 'quartz' cannot be read because it is missing a section declaration
Config File \?\C:\Users\Anbbb\Desktop\TheProject.Web\web.config
<quartz>
24: <add key="quartz.scheduler.instanceName" value="SchedulingPOC"/>
//The configuration section 'quartz' cannot be read because it is missing a section declaration//
Do you have the "section name" defined in "configSections" ??
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
PS
I have a "working" AdoStore example at this post:
Connecting Quartz to MS Sql Server
(One of the answers, not the question)
=======
EDIT
Here is my complete and fully working Quart.Net config, using a SqlServer database.
It ~~assumes~~ you have already created the database.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzSchedulerFromConfigFileSqlServer"/>
<add key="quartz.scheduler.instanceId" value="instance_one"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="Normal"/>
<!--
org.quartz.scheduler.idleWaitTime
Is the amount of time in milliseconds that the scheduler will wait before re-queries for available triggers when the scheduler is otherwise idle. Normally you should not have to 'tune' this parameter, unless you're using XA transactions, and are having problems with delayed firings of triggers that should fire immediately.
It defaults to every 30 seconds until it finds a trigger. Once it finds any triggers, it gets the time of the next trigger to fire and stops checking until then, unless a trigger changes. -->
<add key="quartz.scheduler.idleWaitTime" value ="5000"/>
<!-- Misfire : see http://nurkiewicz.blogspot.com/2012/04/quartz-scheduler-misfire-instructions.html -->
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"/>
<add key="quartz.jobStore.tablePrefix" value="QRTZ_"/>
<add key="quartz.jobStore.clustered" value="false"/>
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>
<add key="quartz.jobStore.dataSource" value="MySqlServerFullVersion"/>
<!-- connectionStringName -->
<!-- "true" below will result in Couldn't store job: JobDataMap values must be Strings when the 'useProperties' property is set. Key of offending value: myFloatValue
exception. -->
<!-- <add key="quartz.jobStore.useProperties" value="true"/> -->
<add key="quartz.jobStore.useProperties" value="false"/>
<add key="quartz.dataSource.MySqlServerFullVersion.connectionString" value="Server=MyServer\MyInstance;Database=QuartzDB;Trusted_Connection=True;Application Name='quartz_config';"/>
<add key="quartz.dataSource.MySqlServerFullVersion.provider" value="SqlServer-20"/>
</quartz>
</configuration>
This code should work....
NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
You must change your connection string to an EXISTING database.....that is the Quartz database.....creating using the scripts provided in one of the downloadable projects.
Like this maybe:
https://subversion.assembla.com/svn/pms_michael/database/tables/tables_sqlServer.sql
I'm unable to get Azure Diagnostics to spit out any of my Trace messages - even in the near-as-is VS2012 project template. Here is what I did:
In an empty VS2012, created a new Cloud project (called it "Azure.Diag")
In the wizards next step, added the default template for "WCF Service Web Role" (called it "WCFService.WebRole")
Editted Web.Config to enable Diagnostics (details below)
Editted WebRole.cs to spit a Diagnostic Trace message (details below)
Ran it locally in Azure Emulator (ServiceConfiguration.Local.cscfg: Diagnostics.ConnectionString is "UseDevelopmentStorage=true")
Look at C:\Users\<Username>\AppData\Local\dftmp\Resources\<Instance GUID>\directory\WCFService.WebRole.svclog => see nothing!
There is also nothing in the Local Storage Blog either (not surprising given the folder before move-to-blob is empty)
How can I get this working? I'm trying to avoid my own handwritten .txt logs to leverage the in built trace listener framework (and parsing tools).
WebRole.cs
using System.Diagnostics;
namespace WCFService.WebRole
{
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
// To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config
DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
string message = "Houston, tracing is broken!";
Trace.TraceError(message);
Trace.TraceInformation(message);
Trace.TraceWarning(message);
Trace.WriteLine(message);
return base.OnStart();
}
}
}
Web.Config:
I used the standard template one but uncommented the top portion (had to merge the two system.diagnostic portions to avoid HTTP 500)
<system.diagnostics>
<sharedListeners>
<add name="AzureLocalStorage" type="WCFService.WebRole.AzureLocalStorageTraceListener, WCFService.WebRole" />
</sharedListeners>
<!--<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="AzureLocalStorage"/>
</listeners>
</source>
</sources>-->
<trace autoflush="true">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
I have got a Web.Release.config that is successfully transforming a connection string.
When I add a microsoft.identityModel section I get a warning saying
The 'http://schemas.microsoft.com/XML-Document-Transform' attribute is
not declared
And the transform doesnt work on that section.
What am I missing to get the transform to work?
Complete Web.Release.config here
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MYNAME"
connectionString="metadata=res://*/Models.MYCOMPANY-Sales-Demo.csdl|res://*/Models.MYCOMPANY-Sales-Demo.ssdl|res://*/Models.MYCOMPANY-Sales-Demo.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=MYCOMPANYDemo;UID=MYCOMPANYDBUser;Password=********;multipleactiveresultsets=True;App=EntityFramework""
xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
<microsoft.identityModel>
<service>
<audienceUris>
<add value="http://MYCOMPANY-sales-demo.cloudapp.net/" xdt:Transform="Replace"/>
</audienceUris>
<federatedAuthentication>
<wsFederation realm="http://MYCOMPANY-sales-demo.cloudapp.net/" xdt:Transform="SetAttributes(realm)" />
</federatedAuthentication>
</service>
</microsoft.identityModel>
</configuration>
I've run into this also but have gotten it to work. What I did was a "RemoveAll" and an "Insert" instead of a replace/match:
<audienceUris>
<add xdt:Transform="RemoveAll" />
<add value="http://example.com/" xdt:Transform="Insert" />
</audienceUris>
When I do it that way I get the desired transform and output config file.
This appears to be working now with Visual Studio 2012 (v4.5.50709). I still get the 'attribute is not declared' warning in the editor, but the xdt:Transform="Replace" directive is working for me.
I've got the PubSub sample working with a distributor in the middle - all of them on my local machine. Now I'm trying to get the distributor on to a different machine and having trouble. The subscribers seem to be getting registered with the publisher via the distributor (I've added log statements in the Publisher which tells me the number of subscribers and that gives me the right value), but the subscriber just doesn't get any of the published events. What am I doing wrong? Is there some permissions I need to provide for the different queues?
Here're my config files:
Publisher:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig InputQueue="MyPublisherInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig DistributorControlAddress=""
DistributorDataAddress=""
ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
<add Messages="MyMessages" Endpoint="distributorDataBus#rosmi" />
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
Subscriber:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig
InputQueue="Subscriber1InputQueue_1"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<UnicastBusConfig DistributorControlAddress="distributorControlBus#rosmi" DistributorDataAddress="distributorDataBus#rosmi">
<MessageEndpointMappings>
<add Messages="MyMessages" Endpoint="MyPublisherInputQueue" /> <!-- I've also tried this with MyPublisherInputQueue#rrajagop -->
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
Distributor:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="NumberOfWorkerThreads" value="1"/>
<add key="DataInputQueue" value="distributorDataBus"/>
<add key="ControlInputQueue" value="distributorControlBus"/>
<add key="ErrorQueue" value="error"/>
<add key="StorageQueue" value="distributorStorage"/>
<add key="NameSpace" value="http://www.UdiDahan.com"/>
<!-- relevant for a Serialization of "interfaces" or "xml" -->
<add key="Serialization" value="xml"/>
<!-- can be either "xml", or "binary" -->
</appSettings>
</configuration>
In the above config, the distributor is running on a machine called "rosmi" and the publisher and subscriber are running on "rrajagop".
Figured out the problem: the issue was happening because nslookup of the machine name was pointing to the wrong IP address - this was because of DHCP allocating a different IP to the machine, but dns entries taking a while to update.