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