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

Am I allowed to fork threads in a JMS Message listener?  RSS feed

 
Robert Nicholson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me if it's forbidden to fork threads ie. make use of a CompletionService or ExecutorService from within the onMessage message of a JMS Message listener?
 
Ugender Rekulampally
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,
I think you are allowed to fork threads in MDB (onMessage) but not recommended. I think you want to make multiple threads in onMessage() to share the load to process the message to speed it up. But I think instead of you creating multiple threads, you split the message before you even place on the queue and modify your onMessage() according to the small message and that will give the same effect and its safe way too.

But WebLogic and websphere don't recommend to create multiple threads in their app server containers.

Why do you want to create multiple threads in there? can you explain a bit more?

Thanks,
Ugender
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<IfTheQuestionWasNotSpecificallyForMDBs>
Yes you very well can do that. However, i think there is one problem if you are using an autoack i.e. the message consumption gets acknowledged when onMessage() finishes. The problem is that you are still processing the message but you have already acknowledged the message. Now, if your code dies while processing, you will loose the message until and unless you recover and put the message back which again may not be the correct way.
</IfTheQuestionWasNotSpecificallyForMDBs>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!