This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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?
 
Consider Paul's rocket mass heater.
 
subject: Correctly handling javax.resource.spi.UnavailableException in an Inbound Connector