Hi list.
I am considering Hessian for a specific task in the project I am working
at, namely synchronous messages within the same application, that
requires different session/context for sender and receiver. (This would
also allow us to separate client/server in into different applications
in the future).

AFAIK, Hessian does not support any type of sessions spanning several
request, in the manner that SOAP APIs like Axis does. This poses a
problem to us. Since we will transfer N instances of binary data within
a single transaction. I'm thinking something like this
  hessianService.prepareTransaction();
  for(...; i < N; ...) {
    hessianService.transferJavaData(foo);
    hessianService.transferBinaryData(inputStream);
  }
  hessianService.commitTransaction();


Here is my idea for solving this:
In the prepareTransaction() method of the service, I will generate a
unique ID (possibly by having Resin generate a HTTP session). This ID
will be used as the key in a WeakHashMap. The value of the Map is an
object (let's just pretends it's a simple List) that queues the data
(and references to binary data in temp files on disk) until we are ready
to commit.
There would also be a "reaper queue", that holds a (strong) reference to
the data queue object (i.e. List), and a timeout (milliseconds from
January 1, 1970). This time out queue has a reaper thread, that will
wake up now and then, removing the strong references to the queues that
have timed out, and thus letting the garbage collector remove them from
the WeakHashMap in case the client is unable to commit the transaction.

The session ID is returned to the client, and provided by the client in
all subsequent requests, so that the data queue can be found. On every
(transferX()) call to the service, the timeout in the reaper queue is
also updated. When commiting, everything related to this "session" is
explicitly removed, of course.

Qestions:
- Am I making this more complicated that neccessary? Would a simple
try/finally on the client, removing all data regardless of outcome, be
enought (until we actually separate the applications)?
- Is there a better, yet robust, way to do this?
- Should I be using something other than Hessian...? Is there a way to
use JMS without having to keep all the binary data in memory?

Thanks in advance,

 /Mattias Jiderhamn


_______________________________________________
hessian-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/hessian-interest

Reply via email to