aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector" Watch "Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector" New topic
Author

Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector

Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
I have a scenario where there is an Inbound Adapter with heavy inflow of messages.

There could be a scenario where all the MDBs are busy servicing the requests for previous messages, i might get additional messages coming in.
In This case we will have to wait till one of the MDB frees up from servicing the message so that the pending message can then be delivered it for servicing.
I have thought if using wait and notify for this purpose and implemented it as below.

1. The connections from the clients are long lived and the client continues to send the messages over the same connection. One thread will be listening to this socket and accept incoming messages. We will call this thread A.
2. Thread A then spawns another Thread to deliver the message to the endpoint, this is a short lived thread and will return after the message delivery is done. We will call this thread B.

I am not using Threads to handle this but Submitting Work to the WorkManager.

Below is the code for the run method of the Thread(Work) B



The above code looks ok to me but i am getting a lots of java.lang.IllegalMonitorException. Can anybody explain the reason for the same or suggest a better way to handle UnavailableException?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector