The Request-Reply Object sample demonstrates request-reply messaging with an object payload.
In request-reply, the message sender expects a reply back. A request message from a sender can be replied to by any matching subscriber. The sender blocks waiting for a response after sending the request.
In this sample, the “Sender” program acts as a publisher and subscriber. The party’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 “ContactRequester” which is the Id of the party that is being used. “ContactRequester” can be found in this sample’s Neuron solution in the Messaging tab under “Publishers” and “Subscribers”. Similarly, the “Receiver” program acts as a publisher and subscriber and its party Id, which is “ContactResponder”, 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. Also, the party sending the request does not need receive rights to the topic being used to receive the response nor does the responding party need send rights to send back the reply. So, in other words, the “ContactRequester” party could be only a publisher and the “ContactResponder” party could be only a subscriber if the user chooses to do so.
This sample is located in the samples hierarchy at Samples\Patterns\RequestReply\RequestReplyObject.
Running the Sample
Open the Sample
To open this sample, see the topic Using the Neuron Samples and select the Request Reply sample.
Before running this sample, follow these instructions:
- In the Visual Studio project that opens, add a reference to Neuron.Esb.dll in both the Receiver and Server projects.
- Build the solution.
- Use Visual Studio to start up all projects.
- Once all programs have connected to the ESB, press <ENTER> on the sender to initiate communication.
- As the sample runs, the sender’s requests are responded to, and the sender displays the response information.