Skip to content

Latest commit

 

History

History
65 lines (38 loc) · 1.77 KB

native-integration.md

File metadata and controls

65 lines (38 loc) · 1.77 KB
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.

Native send

The native send helper methods

Sending involves the following actions:

  • Creating and serializing headers.
  • Writing a message body directly to MSMQ.

In C#

snippet: msmq-nativesend

In PowerShell

snippet: msmq-nativesend-powershell

Using the native send helper methods

In C#

snippet: msmq-nativesend-usage

In PowerShell

snippet: msmq-nativesend-powershell-usage

Return message to source queue

The retry helper methods

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.

In C#

snippet: msmq-return-to-source-queue

In PowerShell

snippet: msmq-return-to-source-queue-powershell

Using the retry helper methods

snippet: msmq-return-to-source-queue-usage