code: protected void commitIfNecessary(Session session, List<Message> messages) throws JMSException {
          // Commit session or acknowledge message.
          if (session.getTransacted()) {
              // Commit necessary - but avoid commit call within a JTA transaction.
              if (isSessionLocallyTransacted(session)) {
                  // Transacted session created by this container -> commit.
                  JmsUtils.commitIfNecessary(session);
              }
          } else if (messages != null && isClientAcknowledge(session)) {
              for (Message message : messages) {
                  message.acknowledge();
              }
          }
      }
docs: Variant of {@link AbstractMessageListenerContainer#commitIfNecessary(Session, Message)} that performs the activity for a batch of messages.
  @param session the JMS Session to commit
  @param messages the messages to acknowledge
  @throws javax.jms.JMSException in case of commit failure