title | summary | reviewed | component |
---|---|---|---|
MSMQ native integration |
Sample code and scripts to facilitate native integration scenarios with MSMQ. |
2024-08-06 |
MsmqTransport |
This document describes how to consume messages from and send messages to non-NServiceBus endpoints via MSMQ in integration scenarios.
These examples use the System.Messaging and System.Transactions assemblies.
Warning
The Systems.Messaging
namespace is unavailable in .NET Core.
Note
When using the C# code samples, add the proper includes for the System.Messaging
and System.Transactions
assemblies in the program using these functions. When using the PowerShell scripts, include these assemblies by calling Add-Type
in the script.
Sending involves the following actions:
- Creating and serializing headers.
- Writing a message body directly to MSMQ.
snippet: msmq-nativesend
snippet: msmq-nativesend-powershell
snippet: msmq-nativesend-usage
snippet: msmq-nativesend-powershell-usage
Retrying a message involves the following actions:
- Reading a message from the error queue.
- Extracting the failed queue from the headers.
- Forwarding that message to the failed queue name so it can be retried.
snippet: msmq-return-to-source-queue
snippet: msmq-return-to-source-queue-powershell
snippet: msmq-return-to-source-queue-usage