The same article in the TechNet.
If you are working with queues in BizTalk Server, the most possible it is the MSMQ (in my experience).
MSMQ is an old man of the Microsoft technology stack. It was created when there were no good standards for messaging. Now MSMQ is wrapped partly in the .NET System.Messaging namespace. It is just a small facelift. MSMQ is still a proprietary technology without well-defined messaging protocol. It means, you cannot use the MSMQ messaging protocol without MSMQ itself.
Now we see vortex of new messaging standards and technologies. One on the top is the AMQP standard and one of the bold implementation of AMQP is the RabbitMQ.
It is one more protocol, one more messaging system which, for sure, can be integrated with BizTalk Server.
Here I will implement the standard queue messaging: sending and receiving messages from BizTalk down through the RabbitMQ queue. I am using the WCF-Custom LOB Adapter (provided from BizTalk side) and the WCF RabbitMQ Binding (provided from RabbitMQ side) to link two systems.
Installation and preparation
Assuming the BizTalk Server and the Visual Studio 2010 are also installed.
Installing RabbitMQ Service
- Go to the RabbitMQ site and download the last versions of server and client for Windows. For me it was rabbitmq-server-2.7.1.exe and rabbitmq-dotnet-client-2.7.1-dotnet-3.0.zip. Client includes the WCF binding which I will use lately. There are several good manuals: rabbitmq-dotnet-client-2.7.1-user-guide.pdf and rabbitmq-dotnet-client-2.7.1-wcf-service-model.pdf. I was quite impressed by quality distributives and documentation.
- Start rabbitmq--server-x.x.x.exe. It will request to install Erlang. Agree, go to the Erlang site [http://www.erlang.org/] and download it. For me it was Erlang.otp_win32_R15B.exe
- Start Erlang…exe. Installation went smoothly.
- Start rabbitmq--server-x.x.x.exe again. Installation went smoothly.
RabbitMQ service is installed. You can see it in the Services window.
Creating RabbitMQ Client Base Assemblies
Now it is time to install the client for .NET and WCF binding extension. Use this manual.
Downloaded the .msi. Installed it. Hmm… no Rabbit.Client.dll (When I started with Examples, they all need this file. It is a main client dll).
Downloaded the *-dotnet-3.0.zip. Nope, it was wrong.
- We need the last rabbitmq-dotnet-client-2.7.1.zip file. Extract everything from this zip.
- Made a copy of the Local.props.example file to Local.props file in the same root folder.
- Start Visual Studio with RabbitMQDotNetClient.sln and successfully build it. The ..\rabbitmq-dotnet-client-2.7.1\projects\wcf\RabbitMQ.ServiceModel\obj\Debug\RabbitMQ.ServiceModel.dll was created. This dll together with the RabbitMQ.Client.dll are the assemblies used by the RabbitMQ clients.
Set up the RabbitMQ binding extension
Here I really lost a lot of time. It is easy for the C# clients; the RabbitMQ.ServiceModel.Test gives all the information. But we have to use this binding from the WCF-Custom LOB adapter. To do so we have to add the assemblies to GAC, change machine.config, etc. See the WCF LOP Adapter documentation.
- Sign the RabbitMQ.ServiceModel and RabbitMQ.Client projects and GAC-ed them.
- Insert an <add> node into the config section of machine.config:
type="RabbitMQ.ServiceModel.RabbitMQBindingSection, RabbitMQ.ServiceModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=1751e286f1ab778d"/>
I have several machine.config files in folders:
- When the binding extension assembly is placed in GAC, we cannot use the above section in the app.config file! This <add> element should be placed only into the machine.config file. Otherwise it cannot be seen in the binding extension list of the WCF LOB Adapter.
- Use >Gacutil.exe /l RabbitMQ.ServiceModel
to get the real parameters for your assembly.
Which one to use? My VM is 64bit. BizTalk Host of the port is 32bit. BizTalk is the 2010 version. In my case the right file was the C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config.
Finally the RabbitMQ binding installed and we can see it in the Binding Type list for WCF-Custom adapter.
Creating the BizTalk test
I have created two pairs of port for testing.
File RP -> WCF-Custom (RabbitMQ) SP ->
-> WCF-Custom (RabbitMQ RP) -> File RP
I’ve changed only two parameters: “hostname” and “oneWay” and let others be default:
URL-s for the Send and Receive RabbitMQ Ports set up as “soap.amqp://192.168.11.128/Mytest” for both of them.
Let’s test it.
Small text file was dropped into In folder, consumed by Receive Port, went through the RabbitMQ queue, and appeared in Out folder. Success.
- Now the RabbitMQ binding is set up to process only well-formed Xml documents.
- “localhost” as “hostname” works fine.
Using the RabbitMQ Binding Element
The RabbitMQ binding is limited to the Text messaging encoding. If we need to change it or add more binding extensions, we have to use the customBinding type and use the rabbitMQBindingElement together with another element (including another encoding). How to do this?
1. Add the <add> node to the machine.config:
<add name="rabbitMQBindingElement" type="RabbitMQ.ServiceModel.RabbitMQTransportElement, RabbitMQ.ServiceModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=1751e286f1ab778d"/>
2. Change the Receive Location transport parameters. It was the RabbitMQBinding. Change it to the customBinding. The Transport Binding Element has to be changed to the rabbitMQBindingElement. I changed only one parameter: hostname as “localhost”.
3. Test it as previously.
Using RabbitMQ as one more transport for BizTalk and/or WCF applications is possible and straightforward. The learning curve is short. There are not too many issues with setting up the RabbitMQ Service and Client parts. Actually there wasn’t any RabbitMQ part which was exposed to the BizTalk directly. RabbitMQ works only with WCF-Custom adapter and only this adapter communicates with RabbitMQ Service.
Now the RabbitMQ implements limited client functionality for the WCF. RabbitMQ implements the AMQP v.0.9 protocol, not the last version 1.0.
Next steps are to test this solution with different messaging patterns and try to figure out how to use RabbitMQ advantages (if there are some) over the MSMQ. Potentially the advantages are the simplest implementation of the Request/Response and Duplex patterns, better scalability, better performance, better manageability and support.
| posted on Thursday, February 9, 2012 1:18 PM