I'm a newbie to EJB, but here's a mechanism that I've used in the
past to make synchronous calls to methods which need to request
their data in an asynchronousn call/callback model.

Add an additional parameter to your sync. method signature.  This
can be any class of Java object.

In your calling thread, invoke the sync. method and pass in a refernce
to an object of the appropriate class as the additional parameter.

In your sync. method, dispatch your async. request and return.

Now call wait() on the object you passed in -- calling thread now
blocks on this object.

When your async response comes back, call notify() on the
'blocking' object -- calling thread now resumes.

Hope this helps,
p.

----- Original Message -----
From: "Bill Leonard" <[EMAIL PROTECTED]>
Sent: Wednesday, July 04, 2001 1:44 PM
Subject: Sync client reqst to bean that uses async (JMS) component


> I have a client that sends a synchronous request to my session bean and
> expects the response to be sent synchronously.  In order to fulfill the
> request, the session bean talks to a component that uses JMS.  Therefore,
> the session bean publishes the request to the JMS-based component.  Now,
the
> response from the JMS-based component is received only by subscribing to a
> topic.  In order for my session bean to return the response to the client
in
> the same thread (synchronously), it has to do one of the following:
>
> 1) the session bean can poll the destination using the
> MessageConsumer.receive()methods.
> 2) block on some event (??); Its MessageListener code would then receive
the
> published response (in a thread started by the JMS provider).  It would
then
> signal the event on the session_bean.  The session bean would become
> unblocked and return the response to the client.
>
> I know (1) can be done.  Is (2) possible?
>
> Also, I first thought that Message Driven Beans might be helpful but,
after
> reading about them, I see that in the above scenario, I'm still faced with
> trying to get a session bean to act synchronously.  If I used an MDB
instead
> of a session bean, the client would then have to communicate with the MDB
> using publish/subscribe (and I wanted the client to communicate
> synchronously)
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to