1. jms-spec
  2. JMS_SPEC-36

Allow messages to be delivered asynchronously in batches


    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Labels:


      It is proposed that the JMS API be extended to allow messages to be delivered to a MessageListener in batches rather than individually as in JMS 1.1.

      Currently, messages are delivered asynchronously by calling the javax.jms.MessageListener method onMessage(Message message).

      However some applications could process messages more efficiently if they were delivered in batches. Applications would define a new listener class javax.jms.BatchMessageListener with a callback method onMessages(Message[] messages).

      It would be necessary to configure this by adding a new method to javax.jms.MessageConsumer:

      void setBatchMessageListener(BatchMessageListener listener, int batchSize, long batchTimeOut)

      Sets the message consumer's batch message listener. Attempting to set both a message listener and a batch message listener on the same MessageConsumer would cause a javax.jms.IllegalStateException.

      • listener The BatchMessageListener being set
      • batchSize If set to a value greater than zero, messages will be delivered in batches of up to batchSize messages. The actual batch size used may be smaller than this, but it may never be larger.
      • batchTimeOut The maximum number of milliseconds that the JMS provider may defer message delivery for in order to assemble a batch of messages that is as large as possible but no larger than the batch size.


      • If auto-acknowledgement was being used, all messages in the batch would be acknowledged together. Section 4.4.12 "Duplicate Delivery of Messages" of the JMS 1.1 spec explains that when auto-acknowledgement is being used, if a failure occurs, clients can't know for sure whether the message has been successfully acknowledged, and so the last consumed message may may be redelivered. This section would need to be extended to state that in the case of batch delivery, if a failure occurs, all messages in the last batch may be redelivered.
      • If dups-ok acknowledgement was being used, message acknowledgement would follow existing semantics.
      • If client acknowledgement, or local or global transactions, were being used then message acknowledgement would follow existing semantics, which is that a call to acknowledge(), or the commit of the transaction, would acknowledge all unacknowledged messages delivered by the session.

        Issue Links



            • Assignee:
              Nigel Deakin
            • Votes:
              4 Vote for this issue
              1 Start watching this issue


              • Created: