• Post Reply Bookmark Topic Watch Topic
  • New Topic

Improve performance for MDB

 
Joe Cheung
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a Message-Driven Bean application to receive message from a MQ. In fact, I anitcipate the application will receive around 10,000 messages a day and it has to do some operations like formatting data and conversion. If it process the message sequentially (one by one). It may take long time to complete. To improve the perf., I am thinking of using mutli-thread to do the operations once message comes in so that the MDB can retrieve another new message as soon as it pass the previous message to the thread for processing with the code snippet shown below:

public void onMessage(javax.jms.Message msg) {
try {
// Suppose t1 is a thread object
t1.process(msg);
}
}

Do you think it is a good approach to process the message efficiently? Do you have any better suggestion to process the messages as fast as possible?

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of points: if the process is asynchronous why does the time taken to process the message matter? Also, are you remembering that the EJB specification specifically preculdes you from starting threads in EJBs?
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBs, including MDBs, are scalable. The server should have a pool of MDBs that process the messages in parallel. So, the principal suggestion here is to relax , and in the rare cases when this is not sufficient, look into the server configuration options.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Paul said , there are couple of things that the ejb specification says no to.Creating and running threads within the EJB in one of them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!