jsr343-experts@jms-spec.java.net

[jsr343-experts] Batch processing...

From: Clebert Suconic <clebert.suconic_at_gmail.com>
Date: Tue, 26 Jul 2011 15:30:45 -0500

Did we add a JIRA or discussed this before? I lost track of it...


It would be nice to have something like this:



On a MessageConsumer


@SomeAnnotation(batchSize=50)
public void onMessage(Message[] messages)



or on the Consumer...


setBatchListener(lMessageListener, batchSize);



Maybe we would be able to extend this to MDBs at some point.

If using Auto-ACK, those messages would all be ACKed in a single batch.

When MDB extends this, we could have MDBs adding transaction support.




I'm proposing this because it's a common problem among message
processing. When you have an event, you are forced to make a
transaction for each message you receive.


Users would be able to do optimizations like this:


public void onmessage(Message[] messages)
{
     Money ammount = new SomePseudoObjectMoney(); // whatever you wnat here

     for (Message msg : messages)
     {
          ammount.add(msg.getWhateverNumberProperty());
     }


     // you didn't need to make 100 updates here, a single update was fine!
     // and a single commit also.
     database.update(ammount);

}





It would be nice to have this as part of the spec, instead of being a
proprietary extension.


It would be a nice feature to JMS IMO.