Wednesday, September 12, 2007

Sending large messages to MSMQ via Dynamic Send Ports

I had troubles figuring out how to send large messages to MSMQ when using a dynamic send port in BizTalk. Developing a connection to MSMQ with "late binding" is straightforward, as you just have to configure a send port - however, doing this via code is less easy.

However, if you follow these steps, it's not a big clue:

1. Create a queue in Computer Management > Services and Applications > Message Queuing.

2. In your BizTalk Projekt, import the library Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapterProperties.dll, stored in %Program Files%\Microsoft BizTalk Server 2006.

3. In a construct message shape, assign the following port properties to the output message:

// to set the admin queue:
Message(MSMQ.AdministrationQueue) = @"FORMATNAME:DIRECT=OS:.\PRIVATE$\MSMQADMINQUEUE";

// to make it transactional:
Message(MSMQ.Transactional) = true;
Message(MSMQ.MaximumMessageSize) = 10240;
Message(MSMQ.SegmentationSupport) = true;

// to assign a special name:
Message(MSMQ.Label) = System.Convert.ToString("ABC");

... and define the target MSMQ queue in the send port object:

SendPort(Microsoft.XLANGs.BaseTypes.Address) = @"msmq://FORMATNAME:DIRECT=OS:.\PRIVATE$\TESTMSMQ";


Voilà!

Thanks to Scott Colestock (http://www.traceofthought.net/PermaLink,guid,cbd9b038-f952-479c-85b2-84398c451623.aspx) and MSDN's MSMQ Properties Page (http://msdn2.microsoft.com/en-us/library/aa577593.aspx)

1 comment:

Christoph said...

If you can't find Message Queuing, in the Computer Management Console, the service is not running. You have to start it manually or need to install it :-)