aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Need to synchronize objet in a MDB (Not resolved) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Need to synchronize objet in a MDB (Not resolved)" Watch "Need to synchronize objet in a MDB (Not resolved)" New topic
Author

Need to synchronize objet in a MDB (Not resolved)

Richard Bedard
Greenhorn

Joined: Oct 14, 2008
Posts: 2
Hi,
I need to synchronize an object in a MDB. Here is the context:

My MDB receive messages from a RPG application (ISeries platform), the process is asynchronous since the RPG doesn't wait for any reply (for better performance).

Each message contains the username of the logged user, i need to keep data for each user session so i am using a static Map with the username as a key, and a bean for the session object. I didn't find any pattern to keep a user session outside web application, is the static map a good solution?

Since the RPG program isn't waiting for a reply, it can send another request before the current one is complete, we can only process 1 request per client at the same time. So my first solution was like:

Session s = map.getSession(username);
synchronized(s) {
processRequest(....);
}

But then i remember that we cant use synchronized in EJB, one possible solution would be to send a reply to the RPG process thru MQ, but the user will be freezed till the reception of the reply, and that's really not a good solution for us...

Is there a J2EE compliant solution for that problem?

Richard

p.s.: Sorry for my bad english
[ October 15, 2008: Message edited by: Richard Bedard ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Since the RPG program isn't waiting for a reply, it can send another request before the current one is complete, we can only process 1 request per client at the same time. So my first solution was like:

Why can you only process one request per client at the same time? What is limiting you?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Richard Bedard
Greenhorn

Joined: Oct 14, 2008
Posts: 2
Originally posted by Paul Sturrock:

Why can you only process one request per client at the same time? What is limiting you?


Each time the user tab from a field to another in its console, the RPG program send the new value of that field to our java engine, we apply it on the Bean stored in the user session and run DROOLS rules engine, that operation is quite fast since we dont load anything from the database but when the user press the SAVE key, the RPG program, save the data from the screen and save calculated values. After the save, a message is send to the java application to ask a refresh of the bean cached in the user session.

That operation may takes some time and since its asynchronous, the user might in the next screen press TAB, and we don't want to process the message until the refresh operation is over.

1) The user choose an entry to edit
1.1) A message is sent to the java application
1.1.1) The java application load all the data from that entry and store it in the user session. (this is asynchronous)
2) The user tab from a field to another
2.1) A message is sent to the java application with the new value of the field the user user tabbed from.
2.2.1) The bean from the session is refreshed with that new value
2.2.1) Drools is launched

It's possible that the 1.1 operation in not complete when 2.2.1 is executed, and this is where we need to wait.

Richard
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to synchronize objet in a MDB (Not resolved)