New wireformat and client side remoting
timfox Oct 31, 2007 4:54 PMTo kick off the discussion, here are my initial comments on Jeff's wiki:
In the diagram where you map MINA objects to JMS objects, we should remember that the JMS layer is a thin layer on the front.
MINA needs to map to a JMS agnostic layer (which may look a bit like JMS).
I'm thinking like the following:
JMS Agnostic MINA --- -------- ---- IoConnector IoAcceptor \ / \ IoSession/ Connection----Connection------------------ | | | | Session Session / \ \ Producer Consumer Consumer
I think Connection Session and Consumer are good abstractions for generic messaging
But Producer and Browser only live on the JMS side.
Producing messages and browsing can be methods on the agnostic Session class.
IOSession will only need to maintain a map of references to the agnostic objects not the JMS objects.
It will need to maintain such a map so the objects can be called back.
So.. what we end up with is basically similar to the current Dispatcher but on the client side.
In effect the system is *symettrical*. We have a dispatcher on the client side which looks up objects in order to deliver responses, and
we have dispatcher on the server side which looks up objects to deliver requests.
Really requests and responses are the same thing, it's just the direction of travel is different. I think this symetry is aesthetically pleasing which is often a good sign.
Regarding the messages: Perhaps it is not such a good idea to classify the messages as synchronous or asychronous since some messages can be sent either asynchronously or synchronously - a good example is sending a message -for persistent messages they are sent synchronously, for non persistently, but the message being sent is the same.
We should come up with a set of messages (which can be either requests or responses) and the api determines whether they are sent asynchonrous or not.
e.g.
interface OurRemotingAPI()
{
void sendOneWay(...);
void sendBlocking(...);'
Handler registerCallbackHandler(..);
}
Actually, currently the *only* messages we send asynchronously are:
1) consumer change rate
2) messages send (for non persistent messages)
All the rest are synchronous.
We could consider making the following asynchronous:
1) Cancel delivery
2) Start/stop connection
In terms of how to correlate requests and responses to give synchronous calls, it should be fairly simple to do something like the following:
1) Send message with "request id" in message.
2) Block thread and put in map with key of request id.
3) When response comes back, look at request id.
4) Lookup thread in map with that request id and wake it up.
Some kind of wait/notify should do the trick.
Another thing to think about is management messages.
You probably want to define a message type as a management message (or a set of management messsages).
The idea here is the user could send a messages saying "createQueue" or "getNumberOfMeessafesInQueue" or any number of different operations that we currently do via JMX, and get results that way without JMX.
Finally one other thing to think about is how MINA is going to support SSL and HTTP.