This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!