More thoughts, how this might look:
abstract class Packet
{
long correlationID;
}
//Example
class CreateConnectionMessage extends Packet
{
//all the params in here
}
interface Dispatcher
{
Handler registerHandler(int handlerID);
void sendOneWay(Packet packet, int handlerID);
void sendBlocking(Packet packet, int handlerID);
}
interface Handler
{
void handle(Message message);
}
Then you have one instance of the Dispatcher on the client side (clientDispatcher), and
you have another instance of the Dispatcher on the server side (serverDispatcher)
(Remember, it's symmetrical)
Here are some examples of usage:
1) Send a non persistent message to a queue on the server
a) Create a SendMessage message
b) Call sendOneWay on the clientDispatcher
c) Sometime later on the server side the serverDispatcher receives the message and calls
handle() on the Handler instance that was registered on the server side to handle message
sends
2) Send a persistent message to a queue on the server
same a) b) c) as above but the
d) server invokes sendOneWay() on the serverDispatcher with a message instance
representing the response with the corelation id set.
e) clientDispatcher receives the message and looks up correlation id in its internal map,
unblocks thread with result.
3) Send a message from server to consumer on client
a) [The consumer will already have registered a handler with the client Dispatcher]
b) Server invokes sendOneWay() on the serverDispatcher with the message instance.
c) The clientDispatcher receives the mesage, looks up the appropriate handler and invokes
handle() on it.
d) Notice that there is no need for the clientDispatcher to have specific knowledge of the
session and consumer objects - all it needs
to know about are handlers! Nice and simple huh?
4) Non blocking reliable send of message (this is over and above JMS)
a) client invokes sendOneWay()on clientDispatcher with a message
b) client carries on doing something else
c) server receives message looks up handler and invokes handle() on it.
d) server persists message and calls sendOneWay() on the serverDispatcher
e) server carries on doing something else
f) client receives message on calls handle() on response handler.
g) Now client knows that messages was persisted, but since non blocking can get much
better throughput not limited by network RTT
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100857#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...