views:

404

answers:

1

I have an application that does a delayed operation. User generates 1 million messages that are stored in the JMS Queue and then a MDBeans are consuming these messages and performing some action and storing data in the database. Since JMS Queue is working too fast, it tries to create 1 million MDBean instances which in turn try to create 1 million database connections. No surprise that some of them timeout since JDBC connection pool cannot serve 1 million connection requests.

What is the best solution to control the number of MDBeans created? It would be better that 1 million messages would be processed by a certain number of MDBeans that is not exceeding the number of allowed connections in JDBC pool

+1  A: 

You can limit the number of instances of your MDB by using the max-beans-in-free-pool element within the descriptor for your bean in weblogic-ejb-jar.xml.

<message-driven-descriptor>
   <pool>
      <max-beans-in-free-pool>100</max-beans-in-free-pool>
      <initial-beans-in-free-pool>50</initial-beans-in-free-pool>
   </pool>
   ...
</message-driven-descriptor>

If left unspecified, the number of instances created will only be bounded by the number of threads available. Regardless, it is good practice to set the maximum number of threads equal to or lower than the size of your database connection pool.

Chris Thornhill