How to send MSMQ messages over 4MB in size – #1: Using MQRTLARGE.DLL

As writing a blog that covered all the options might get a bit cumbersome (like my Insufficient Resources post), I’m splitting the different approaches up into their own separate posts. The first will be about using the BizTalk Message Queuing Large Message Extension (MQRTLARGE.DLL).

To use the DLL you need to make use of the BizTalk Message Queuing Large Message Extension API, an add-on for native message queuing.

“Native message queuing cannot process a message with a body larger than 4 megabytes (MB). However, Microsoft® BizTalk® Server 2004 includes an add-on for native message queuing that permits processing messages larger than 4MB. This add-on is delivered as the Mqrtlarge.dll file, and exposes the MQSendLargeMessage and MQReceiveLargeMessage application programming interfaces (APIs), and the analogous COM model. These functions are implemented as standard message queuing APIs, MQSendMessage and MQReceiveMessage respectively.

To participate in large message exchanges, the message queuing computer must have the Mqrtlarge.dll file installed, and the message queuing application should use the add-on APIs. Otherwise, complete messages will be fragmented.”

Although the API has “BizTalk” in the name it doesn’t mean you must have BizTalk installed anywhere to send large messages. All you need is code inside the application that calls MQRTLARGE.DLL “*Large*” API versions instead of the regular MSMQ API. Saying that, though, the DLL was ONLY shipped with BizTalk to provide large message access and so it is not supported in non-BizTalk configurations – just because it seems to work doesn’t mean Microsoft has tested and approved it.

This MSDN article Large Message to MSMQT (BizTalk Server Sample) has a sample demonstration on sending messages to MSMQ/T which can be used for ideas on writing your own MSMQ-MSMQ application.
Note: there are some minor code omissions in the sample that are documented in KnowledgeBase article 897294:

You may receive a “System.Runtime.InteropServices.COMException” exception error when you try to send a large message by using the Large Message to MSMQT sample application in BizTalk Server 2004

To get hold of the DLL, you need to download the BizTalk Server 2004 SDK.
Note: The link is just for the update to the SDK and, when you run the EXE, it will complain if BizTalk is not already installed. So (assuming you don’t have BizTalk installed), with the “unable to find the BizTalk Server 2004 install path” dialogue box still on the screen, have a look in your Temp directory for the extracted files. MQRTLARGE.DLL should be in the <something>.TMP\Samples\Adapters\MSMQTLarge\LargeApi sub-directory.

Eldar Musayev wrote a useful blog posting back in June 2005 called “Really large messages with MSMQT and MSMQ (MSMQ/C) Adapter” which has some good points on memory capacity, etc. If you have any questions for Eldar then don’t bother commenting this post as the whole blog has been retired (i.e. left available for reference but no longer being updated). Eldar has also changed product focus to Windows Home Server so will have already been brain-wiped of all Biztalk knowledge a while ago.

Comments (3)

  1. Dhaval Patel says:

    Thanks again, John. Looking forward to the other posts in this series… This also brings up another possibility: How would this solution stack up against the SQL Server Integration Services’ "Message Queue Task?" You don’t have to answer that if you can’t, but you can imagine my curiosity surround MSMQ 🙂

  2. Shally says:

    Thanks. It is very helpful.

    How do I receive the 4MB+ message which BizTalk sends to a MSMQ. The whole message becomes multiple small messages in the queue.

  3. MSDN Archive says:

    Hi Shally,

    MSMQ has some properties which can be used for this purpose. Every transactional message has a transaction ID in PROPID_M_XACTID. All messages sent in the same transaction have the same ID. This is supplied automatically by MSMQ.

    I’m not sure how BizTalk indicates any sequence information within the message. For example, it may make use of PROPID_M_APPSPECIFIC where you could use the low 16 bits for the chunk number, and the high 16 bits for the total number of chunks.

    I’ll see if I can find out from my BizTalk colleagues how it works.

    Also, just for reference:

    198686 How to send files larger than 4 MB by using Microsoft Message Queuing;EN-US;198686