Skip to content

Chat

Overview

Neuron ESB is completely written using the Microsoft .NET Framework. Neuron ESB is deployed as a server solution, but also offers a distributable .NET Neuron ESB Client API that allow users to effectively host the Enterprise Service Bus (ESB) within their own .NET Applications, remote from the central Neuron ESB Server. The Neuron ESB Client API can communicate either with Topics via the central Neuron ESB Server, or directly to other hosted Neuron ESB clients. These hosted Neuron ESB Clients can be easily distributed across the network where Business Processes can be associated with them and executed within the environment they are hosted in.

This sample demonstrates how the Client API can be used to implement a chat application.

Solution components:

  • Microsoft Visual Studio .NET Solution
  • Neuron ESB Solution Configuration

Solution

Microsoft Visual Studio .NET Solution

This sample demonstrates using the Neuron.Esb.Publisher class to connect to Neuron with Party as the PublisherId. The Chat program can send and receive messages. The Chat class implements the OnOnline, OnOffline and OnReceive event handlers. The OnOnline and OnOffline event handlers fire off when the party connects or disconnects from the ESB. In this sample, since the Peer topic transport is used, the OnOnline event will fire off when more than one chat client has connected to the topic and the OnOffline event will fire off when a client(s) disconnects and there is only one client left. This is due to the fact that the Peer transport requires more than one client to create a network (i.e. requires a Peer).

Neuron ESB Solution Configuration

The accompanying Neuron ESB Configuration file named, Chat.esb, is configured to support the Chat sample described in this paper. The configuration file can be opened within the Neuron ESB Explorer. Within it are the following elements:

Neuron Topics

There is one Topic (Party) that has been configured to support publishing the original request message to the bus, as well as routing messages to one or more subscribers.

Note: The Neuron topic used for this sample should be run using the Peer transport type. It will work with other transports but will not wait for other clients to connect to the chat.

Neuron Parties

Neuron ESB Parties are used to communicate to, and receive messages from the Neuron ESB Publishing Services. Every Topic represents an instance of a Neuron ESB Publishing Service. What messages a Neuron ESB Party is allowed to send, and what messages they can receive is determined by what subscriptions are assigned to them. Subscriptions are generally defined by using Topics with the optional addition of Message Patterns.

Note: Message Patterns provide more granularity to Topic based subscriptions through the addition of context and content based routing options.

Neuron ESB Parties can be defined as either a PublisherSubscriber or both. How they are defined is a function of the Topic subscription rights assigned to them- SendReceive or both.

To support this sample, the following Publisher is configured under the Messaging:Topics:Publishers section of the Neuron ESB Explorer:

Name:             Party
Subscriptions:    Chat            Send/Receive

Running the Sample

Open the Sample

To open this sample, see the topic Using the Neuron Samples and select the Chat 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 and build the solution.
  2. Open Windows Explorer and navigate to <Program Files>\Neudesic\Neuron ESB v3\Samples\Scenarios\Chat\bin\Debug.
  3. Double-click Chat.exe two or more times to open any number of chat sessions.

Run the Sample

  1. Each Chat session that starts will prompt you for a nickname.
Chat session - nickname.
  1. Enter a nickname and press Enter. When the first client connects, it waits for additional clients to connect.
Waiting for other parties to join
  1. When at least one more client has connected, you can begin chatting.
Begin chat with at least one client
  1. Type any message into any of the chat sessions that are open. The message will be broadcast to the other chat sessions.
Start chatting
  1. When finished, close all the chat sessions.
Was this article helpful?
Dislike 0
Previous: Business Process to Workflow Sample
Next: Scheduler Custom Job Sample