Share via


BizTalk MSMQ Adapter and the MsmqAdapterProperties.dll

I have been working on an application which needs to send a message to a queue in which the queue location was contained in the incoming XML Message.  This was simple as you can just set the send port binding to Dynamic and provide the address through a distinguished field using an expression shape and the following code; MSMQSend(Microsoft.XLANGs.BaseTypes.Address) = <DistinguishedAddressField>;.  The address needs to be in the following syntax; "MSMQ://FORMATNAME:DIRECT=OS:MachineName/Private$/QueueName.

 

The difficult part came into play when I then needed to set a label on the outgoing message as well as set the queue transaction property to true (which by default is false).

 

When I looked at all of the properties available through the Message Assignment shape on the outgoing message there were no properties available for MSMQ.  However, all of the standard properties were available including the MSMQ/T properties.

 

What I found is that you need to add a reference to the MsmqAdapterProperties.dll to the orchestration project.  This DLL is found in the directory in which you installed the MSMQ Adapter (Program Files\Microsoft BizTalk 2004 Adapter for MSMQ).  Once this DLL was added I was able to see all of the MSMQ specific context properties that I would expect to see when dealing with MSMQ.

 

So, to set a label on the outgoing messages add the following line of code in the expression editor

   <MessageName>(MSMQ.Label) = "Label";

 

Also listed was the transactional property.

 

In addition, if there are errors sending the message the message will not reach the remote queue but instead will be placed in the local dead letter queue.