Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Publishing to multiple queues from NServiceBus September 9, 2010

Filed under: NServiceBus — Rupert Bates @ 3:38 pm

Something that I found a bit confusing when setting up NServiceBus, was working out how to publish to multiple queues when I have a number of different services and message types.

The project structure I have is:

MyProject.WebApp – handles config and takes commands from user

MyProject.Messaging – defines messages and has utility classes for publishing which are called by the web app

Myproject.Service1 – reads from a message queue and does something with one type of message

Myproject.Service2 – reads from a different message queue and does something with another type of message

etc.

The confusion I had was around how to configure my web app to send different types of message to the correct queue, all the documentation is there on the NServiceBus site, it’s just not that easy to apply.

It turns out the solution is actually very simple, in the config for my web app I just need to include the message type names and the assembly they appear in to map those types to the correct queue, as follows:

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messaging.MessageType1, MyApp.Messaging" Endpoint="MyApp.Service1.InputQueue"/>
      <add Messages="MyApp.Messaging.MessageType2, MyApp.Messaging" Endpoint="MyApp.Service2.InputQueue"/>
    </MessageEndpointMappings>
  </UnicastBusConfig>
 

Run NServiceBus generic host as 32bit process on 64bit machine September 7, 2010

Filed under: Error,NServiceBus,Systems Administration — Rupert Bates @ 3:37 pm

I recently encountered the following error when deploying a service in the NServiceBus generic host (NServiceBus.Host.exe) on a 64bit machine,


System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.

It turns out that this is actually a symptom of a problem which can show itself in a number of ways and is caused by running a service which depends on a 32bit dll (in this case the Microsoft Jet drivers) on a 64bit system in the generic host.

To fix it you can create a version of the generic host which is configured to run as 32bit as follows:

Run a visual studio command prompt and cd to the directory where NServiceBus.Host.exe is.  You will also need the NServiceBus.snk file from the NServiceBus download in the same directory so that you can resign the assembly after configuring it

At the command prompt type:

corflags /32BIT+ /Force NServiceBus.Host.exe

sn -R NserviceBus.Host.exe NServiceBus.snk

You can now deploy this version of the host onto your 64bit server and services which use it will run in 32bit mode