Need to wait() Thread in EJB code

?

_

I need to accept a request and then query two systems. I need to send
off the first query to a queue then execute the second query. After
getting the result from the second query I need to wait for a response
from the first query via an MDB before combining the data from both
queries and returning a response.

Of course the first thing about EJBs is that you can't muck around
waiting and notifying threads so how can I do this.

Options

Some JBoss specific classes that are safe to use. But I'll want to
move to WebSphere next year.

Implement this as a separate stand-alone non-J2EE server.

Use some J2EE API designed for this purpose. Am I missing this?
 
J

Jon Martin Solaas

_ said:
I need to accept a request and then query two systems. I need to
send off the first query to a queue then execute the second query.
After getting the result from the second query I need to wait for a
response from the first query via an MDB before combining the data from
both queries and returning a response.

Of course the first thing about EJBs is that you can't muck around
waiting and notifying threads so how can I do this.

Options

Some JBoss specific classes that are safe to use. But I'll want to
move to WebSphere next year.

Implement this as a separate stand-alone non-J2EE server.

Use some J2EE API designed for this purpose. Am I missing this?

Put the result from the second query into a buffer and pick it up when
your MDB is triggered by the result of the first query.

The buffer could be anything from a singleton to a database table,
depending on lots of things that I don't know anything about :) Anyway,
I don't think you have to write stuff that breaks portability and the
J2EE standard to achieve this. Just make sure the buffer won't become a
bottleneck.
 
?

_

Thanks for the suggestion Jon. One of my main objectives is to devise
a solution that works inside the J2EE container. Your solution does
work for a setup where a client is sending queries and concurrently
listening for responses to past queries. Unfortunately I also have the
situation where the initial request thread is fired up by an HTTP
request and so needs to wind up by building a response and returning
that to the browser. I also don't know which query will finish first.
Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top