Skip to content

Direct Messaging

Overview

The Direct Messaging Object sample demonstrates point-to-point messaging with an object payload. In direct messaging, the sender specifies the party Id of the recipient. Only that recipient sees the message.

In this sample, the “Sender” program acts as a publisher. The publisher’s Id is contained in the program’s App.config file in the XPath “configuration/appSettings” as an “add” element. The key for the “add” element is “esbClientId” and the value is “ContactSender” which is the Id of the publisher that is being used. “ContactSender” can be found in this sample’s Neuron solution in the Messaging tab under “Publishers”. Similarly, the “Receiver” program acts as a subscriber and its subscriber Id can be found in the App.config file for the “Receiver” program.

As an alternative to using the App.config file to set the Publisher or Subscriber Id, they can be set programmatically when creating the Publisher or Subscriber object by passing in a string containing the Id of the Publisher or Subscriber to the constructor.

This sample is located in the samples hierarchy at Samples\Patterns\DirectMessaging\DirectMessagingObject.

Running the Sample

Open the Sample

To open this sample, see the topic Using the Neuron Samples and select the Direct Messaging sample.

Setup Instructions

Before running this sample, follow these instructions:

  1. In the Visual Studio project that opens, add a reference to Neuron.Esb.dll in both the Receiver and Server projects.
  2. Build the solution.

Run Instructions

  1. Use Visual Studio to start up all projects.
  2. Once all programs have connected to Neuron ESB, press Enter on the sender to initiate communication.
Figure 1: The Sender program before sending the message
  1. As the sample runs, the receiver program receives messages because its party ID matches the ID specified by the sender.
Figure 2: The Receiver program after receiving the messages
Was this article helpful?
Dislike 0
Next: Failed Message Routing