I am using the bundled JMS implementation on Wildfly 8.1 (HornetQ) to OCR a large number of documents.
I want to have a pool of 3 MDBs consuming the messages of a Queue with the documents to be OCRed. Each MDB starts a process with the Apache commons-exec and blocks until that process exits.
In my test I have 50 JMS messages (each represents a document to be OCRed) which are loaded on the Queue at the beginning of the test. When the processing starts, at any given time I can see that there are 3 CPU intensive OCR processes, one started and blocked upon by each MDB. At some point, after 20 minutes or so, one of the OCR processes dissappears, and only 2 remain alive at any given time. When there are 10 JMS messages or so remaining, another OCR process stops, and there is only 1 at any given time.
In the end, all 50 documents have been OCRed, and no exception is being thrown by any of the OCR processes or my application.
I find this behaviour strange because I would expect that there would be 3 OCR processes alive at any point in time consuming JMS messages (except at the end of course). This behaviour could be explained if the JMS messages are "assigned" to the MDB instances upon entry in the Queue, and not real time. For instance, if each MDB was assigned around 17 messages. Depending on the document sizes, some MDB instances could finish earlier and stay idle without consuming any other messages, when the other MDB instances could still have messages to consume.
Is this what is happening? If yes, is there a way to change this so that the assignment of messages to MDB instances happens whenever an MDB instance finishes processing a message?
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/csrOcrQueue"),
@ActivationConfigProperty(propertyName = "minSession", propertyValue = "3"),
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "3")
})
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class OcrMessageListener implements MessageListener {