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:
|
|
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.
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.
Neuron ESB Parties can be defined as either a Publisher, Subscriber or both. How they are defined is a function of the Topic subscription rights assigned to them- Send, Receive 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:
- In the Visual Studio project that opens, add a reference to Neuron.Esb.dll and build the solution.
- Open Windows Explorer and navigate to <Program Files>\Neudesic\Neuron ESB v3\Samples\Scenarios\Chat\bin\Debug.
- Double-click Chat.exe two or more times to open any number of chat sessions.
Run the Sample
- Each Chat session that starts will prompt you for a nickname.
- Enter a nickname and press Enter. When the first client connects, it waits for additional clients to connect.
- When at least one more client has connected, you can begin chatting.
- Type any message into any of the chat sessions that are open. The message will be broadcast to the other chat sessions.
- When finished, close all the chat sessions.