• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Statefulness using JMS

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We plan to use JMS and MDB’s to create a certain service. We need to maintain state between methods, which means between the JMS messages.

To demonstrate using an example , Lets say the service has 2 methods login and book..
I get a JMS message for a login, the service consumes it, and returns a token. Now, I send a JMS message for book, in which I pass the token. I would like book to access the state of login.

I guess the short of it is, I am trying to figure out a way to create statefulness using JMS and MDB’s.

Appreciate ideas on this.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some options that come to my mind..

1] Write something to a database.
2] Put something in Application Context.

-Pallav
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would prefer the database option, but it may not be an option for us.
Can you tell me more about Application Context.
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep in mind , I may not have a servlet. Just JMS and MDB.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the main interest is to return a token to client after login, then probably temporary queue can help?

In short, the idea is that client creates a TemporaryQueue that is associated with Connection object (exist only for this connection lifetime), and pass queue name in its "request" message.
MDB can send a "response" with login token (or whatever else), using this queue name. Client consumes the response.

The approach is described in more details here:
http://onjava.com/pub/a/onjava/2007/04/10/designing-messaging-applications-with-temporary-queues.html?page=1
Hope this could help!
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It involves more than just login. There can be 5 or 8 messages , which need to maintain session data between them.

Looking to see how I can maintain session between session messages ( Besides the database approach )

Thanks

Mahesh
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Emm...what about stateful session beans? This is exactly what they are intended for.
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Iam looking for a solution , with JMS.
 
Anastasia Klimchuk
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about a session data you mentioned, is it something huge or more like several attributes?

What about the following:
After certain client logged in, and recieved back a token from MDB, this token can later be passed to MDB as clientID with all the following messages that belong to the same "conversation".
Or it's possible to pass clientID + some other attribute.
So, session state would be identified by clientID.

Pallav, do you mean application context used by Spring?
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anastasia,

I think in (1) you are talking about sending all the information in the request itself.
(2) - saving in a session on the server, is what Iam trying to figure out.
If you have a servlet, I can see how one can have a session to save data in.

But if there is just a MDB how do you do it. Obviously, the session data should be available across servers.

 
Anastasia Klimchuk
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was talking about sending data in a message that client sends to a MDB, e.g. adding an attribute to message "clientState" or some other attributes. For this case client will send its state every time with a message.

By (2) - saving data on server (and no database), do you mean saving data in MBD for that it could recognize subsequent client calls and individual client data?
I have only one straightforward thought, to have a local hashmap inside an MDB with clientID as a key and session data as a value. But anyway, clientID should be passed in every message... and this all is only for little-sized session data
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Storing in a hashmap, would make it accessible only if the next request goes to the same instance, the hashmap store was done in.
If I have 10 instances of a APP server ( lets say distributed among 5 physical servers ) - it would not work.
 
Anastasia Klimchuk
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, sure

But the possibility to send additional attributes in a message still exist
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic