Package com.nexaweb.server.messaging
Contains server side messaging APIs used for publishing and listening to messages.
See:
Description
|
Interface Summary |
| MessagingService |
The MessagingService allows for system wide messaging. |
Package com.nexaweb.server.messaging Description
Contains server side messaging APIs used for publishing and listening to messages.
Nexaweb Internet Messaging Bus (IMB)
The messaging APIs give you access to the Internet Messaging Bus which connects
multiple clients and servers allowing an exchange of messages between
application components. To receive messages on a particular topic you first
subscribe to that topic providing your own MessageListener.
You can subscribe to a topic from the server or the client side. All messages
published by clients always go to the server first from where they are dispatched
to all topic subscribers. There are no direct client-to-client connections.
Note:The order of subscriber notification is not guaranteed.
Note:Each subscriber will receive all published messages in the
order they were published.
Here is an example path a message takes when published on the client.
Assume Client1 is subscribed to the topic "mytopic" and "message1" is a sample
message.
- Client1 publishes "message1" on "mytopic"
- "message1" travels to the server that the Client1 is connected to
- The server dispatches the message to all "mytopic" subscribers ( including the
client side subscribers of the client that published the message)
- Server side subscribers are called directly while client side subscribers
are notified through a server side proxy. The proxy sends the message to each of the
subscribed clients using any available connection from those clients. This implies
that the clients will only receive the message if or when they make a connection
to the server.
- When the message arrives on the client, the client side subscribers are notified.
- If clustering is enabled all subscribers managed by other servers in the
cluster will also get notified (this includes all clients connected
to those servers that contain subscribers for the topic)
Note:To subscribe to a topic or publish a message you need a connection to the server.
Note:If a client publishes a message on some request, the client's subscribers
are not guaranteed to get notified after the corresponding response returns
since message processing is asynchronous. So the client might get the message
back either on the push connection (if one exists) or whenever it makes the next
request to the server.
Server API
The API consists of only 1 service class: MessagingService. The service is used
to perform system wide messaging from the server side. All MessageListeners
subscribed on clients and servers will hear messages published through this service.
MessageListener can be extended to listen for messages sent across the Nexaweb
Internet Messaging Bus (IMB). Subclasses should override the methods to receive
messages of specific types. The onMessage() variant called will always correspond
to the variant of the publsh() or send() method used to put the message on the IMB.
All messaging on the server side is accessed through the MessagingService. All
messaging on the client side is accessed through the NetService.
A reference to this service may be obtained by calling the static
ServiceManager.getMessagingService() method.
Example Usage:
MessagingService messagingService = ServiceManager.getMessagingService();
messagingService.publish( "MyTopic.MySubTopic", "My message" );
Topics specified to methods defined by this interface must consist only of
alphanumeric characters and the following ( '-', '.', '_', ':' ).
Server Performance Tuning
The dispatch of published messages to subscribers is serviced by the MessagingThreadPool.
The settings for the pool can be adjusted in your application's nexaweb-server.xml.
To get a feel for the pool performance you might want to look at the following
jsp page contained in every Nexaweb application:
<your-appcontext>/Nexaweb/Services/index.jsp
There you can click on the MessagingService tab to see its statistics. Also you
might want to take a look at the Thread Pool Report and All Performance Meters links.
In the frame opening on the right search for the Message Thread Pool statistics.
To get more information about all the different thread pool settings see
nexaweb-server.xml documentation.
Copyright © 2005 Nexaweb Technologies, Inc. All Rights Reserved.