class JMSMessageConsumer {

  List<Event> take() throws JMSException {
    List<Event> result = new ArrayList<Event>(batchSize);
    Message message;
    message = receive();
    if (message != null) {
      result.addAll(messageConverter.convert(message));
      int max = batchSize - 1;
      for (int i = 0; i < max; i++) {
        message = receiveNoWait();
        if (message == null) {
          break;
        }
        result.addAll(messageConverter.convert(message));
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug(String.format("Took batch of %s from %s", result.size(), destination));
    }
    return result;
  }

    JMSMessageConsumer(InitialContext initialContext, ConnectionFactory connectionFactory,
                     String destinationName, JMSDestinationLocator destinationLocator,
                     JMSDestinationType destinationType, String messageSelector, int batchSize,
                     long pollTimeout, JMSMessageConverter messageConverter,
                     Optional<String> userName, Optional<String> password,
                     Optional<String> clientId, boolean createDurableSubscription,
                     String durableSubscriptionName);

}