Ashwin Dinakar wrote:

> I like to continue this discussion. Currently I am using WebLogic as an EJB server. 
>WebLogic does provide JMS. I am thankful for that.
>
> I am still vague about how JMS is a replacement for threads in EJB.
>
> Here is a question I have.
>
> I want a producer to post a message to a queue. I want this message to be picked up 
>asynchronously.
> In order to accomplish this I want to wait inside a method .

Instead of waiting inside a method, it is more reliable and scaleable to have the 
container do the waiting and to call your EJB instance when the message arrives. The 
reasons for this are:

1. If the message is going to arrive tomorrow it is quite unlikely that your server 
will let you wait inside a method for 24 hours. It will crash, or time out the wait or 
kill the method in order to recover its resources and run work for other clients

2. Insufficient EJBs can concurrently wait while holding memory, threads, open 
connections to JMS and possibly other resources before the server runs out of 
resources.

> I want this wait() method to be invoked with a Bean (mostly a session bean).

For the reasons listed above, no you don't.

> According to the Java specification this wait() must be inside a synchronized block 
>(no compile time errors but a IllegalMonitorStateException will be thrown at 
>run-time). Is this a violation of the EJB specification since I am using the keyword 
>"synchronized" within my EJB class.

Yes it's a violation. The EJB architecture is designed to support highly scaleable 
applications, where scaleable means that large numbers of individual clients can call 
the application concurrently. For this to work, the application must be designed to 
start up, acquire resources, do
its work free resources and end quickly. Issuing waits conflicts with this.

> I am having the SessionBean class implement the MessageListener interface.
> Therefore it will implement the onMessage(String msg) method. This onMessage will be 
>invoked by another Thread-call back thread.

Generally, the reason JMS is a substitute for threads is that eventually JMS will be 
able to be used to get asynchronous activities started.

Ian McCallion

===========================================================================
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