Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about J2ee architecture with an mdb and sb  RSS feed

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Suppose I want a SLSB to send over a time-consuming database query to be performed by an MDB. Once the MDB has finished performing its search/query I want the originating client to have the resultset available. How do I do that? My question is where can the MDB store the resultset so that it can be subsequently used by a SFSB or directly by the web tier?
Thanks in advance,
Julien.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An MDB is adding complexity to your design. Do you need it?
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Roger. Howerver how can I achieve a non-blocking call without an MDB?
Julien.
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your original question... Not really. MDB's are an asynchronous solution and have no guarentee of when they will read messages nor that messages will even be read in the order in which they are sent.

So if a client is waiting, you either have to make the call synchronous and not use an MDB (often expensive), or create some kind of trigger that will alert the client to when the MDB has finished, such as auto-reloading a page or checking for the existing of a specific database entry.

If you're looking for an automatic trigger, someone else might be able to provide this, but my best bet would be to have the client check for the existence of a particular record or value in a database.
[ December 11, 2005: Message edited by: Scott Selikoff ]
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Actually what I am trying to emulate is what you see on travel web sites: you enter the flight destination and date and you launch the search and then it takes some time and you see progress bar and then you are given the results. How can I do that with jsp and a session bean??
Julien.
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you really want an MDB for that. You just want to call Session bean and while waiting for a response, do some spin lock work such as presenting a user a graphic that indicates they are waiting.

You need to make use of the flush() command on the output stream so that you can send user data, and when you are ready to finish, just output a redirect META HTML tag so that they get a new page with the saved data (possibly saved in a session object)
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, MDBs are commonly use to perform system-oriented tasks, such as sending messages between two systems. Because of their asychronous nature, they are not often closely tied to a user interface other than to send messages outward during a transaction. No one should ever be waiting on an MDB unless the wait time is expected to be very long and not guarenteed.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Scott,
I found some interesting info about spin locks and busy waiting
-http://en.wikipedia.org/wiki/Spinlock
-http://en.wikipedia.org/wiki/Busy_waiting
What I don't understand is the following:
1. how for the jsp/jsf page to make a non blocking call.
2. how for the SB to notify the jsp/jsf/web tier it has finished processing the request.
Do you know where I could find some sample code??
Julien.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!