How to configure MSMQ message extension using BizTalk MSMQ adapter?

We use BizTalk Server to send messages through MSMQ. The receiving system requires that each message have an extension property set to guid (as a byte array). MSDN documents the Extension property for MSMQMessage here and (in .NET) here .

Just set the extension property in .NET:

const string messageContent = "Message content goes here"; var encodedMessageContent = new UTF8Encoding().GetBytes(messageContent); // Create the message and set its properties: var message = new System.Messaging.Message(); message.BodyStream = new System.IO.MemoryStream(encodedMessageContent); message.Label = "AwesomeMessageLabel"; // Here is the key part: message.Extension = System.Guid.NewGuid().ToByteArray(); // Bonus! Send the message to the awesome transactional queue: const string queueUri = @"FormatName:Direct=OS:localhost\Private$\awesomeness"; using (var transaction = new System.Messaging.MessageQueueTransaction()) { transaction.Begin(); using (var queue = new System.Messaging.MessageQueue(queueUri)) { queue.Send(message, transaction); } transaction.Commit(); } 

However, the BizTalk MSMQ adapter does not support the message extension as something that can be installed (see the list of adapter properties on MSDN ). I also decompiled the Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapter assembly that comes with BizTalk 2013 and cannot find the link on the extension property.

How do I customize the extension of the MSMQ message sent by BizTalk? I would prefer not to create a custom adapter, if possible, since it requires a lot of overhead and ongoing maintenance.

+6
source share
1 answer

Have you seen this article? http://msdn.microsoft.com/en-us/library/aa560725.aspx

This article shows how to programmatically set the MSMQ receive location; in addition, it provides access to additional properties that may be necessary but not shown by the BizTalk adapter by default - (for example, Extension).

 ManagementClass objReceiveLocationClass = new ManagementClass( "root\\MicrosoftBizTalkServer", "MSBTS_ReceiveLocation", null); // Create an instance of the member of the class ManagementObject objReceiveLocation = objReceiveLocationClass.CreateInstance(); // Fill in the properties objReceiveLocation["Name"] = name; objReceiveLocation["ReceivePortName"] = port; objReceiveLocation["AdapterName"] = adapterName; objReceiveLocation["HostName"] = hostName; objReceiveLocation["PipelineName"] = pipeline; objReceiveLocation["CustomCfg"] = customCfg; objReceiveLocation["IsDisabled"] = true; objReceiveLocation["InBoundTransportURL"] = inboundTransport; // Put the options -- creates the receive location objReceiveLocation.Put(options); 

EDIT:

After decompiling the BizTalk MSMQ adapter code to the interface level, I see no way to do this using the default adapter. The adapter cannot be extended either as it is sealed.

The only other options I found are

EDIT: (The reason you SHOULD NOT set the extension property)

The Extension property is used to bind large messages together that are fragmented in the transport if the total message size exceeds 4 MB. This is done under the covers, and if crawling can damage large messages.

To participate in large message exchanges, the Mqrtlarge.dll file must be installed on the computer with the message queue, and the application for message queues must use additional APIs. Otherwise, complete messages will be fragmented.

BizTalk 2004 Extended Message Documentation

BizTalk 2010 High Volume Extensibility Documentation

+3
source

Source: https://habr.com/ru/post/953582/


All Articles