Class BatchingRabbitTemplate

All Implemented Interfaces:
org.springframework.amqp.core.AmqpTemplate, org.springframework.amqp.core.MessageListener, PublisherCallbackChannel.Listener, RabbitOperations, ChannelAwareMessageListener, ListenerContainerAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle

public class BatchingRabbitTemplate extends RabbitTemplate
A RabbitTemplate that permits batching individual messages into a larger message. All send() methods (except send(String, String, org.springframework.amqp.core.Message, org.springframework.amqp.rabbit.connection.CorrelationData)) are eligible for batching.

Experimental - APIs may change.

Since:
1.4.1
  • Constructor Details

    • BatchingRabbitTemplate

      public BatchingRabbitTemplate(BatchingStrategy batchingStrategy, org.springframework.scheduling.TaskScheduler scheduler)
      Create an instance with the supplied parameters.
      Parameters:
      batchingStrategy - the batching strategy.
      scheduler - the scheduler.
    • BatchingRabbitTemplate

      public BatchingRabbitTemplate(ConnectionFactory connectionFactory, BatchingStrategy batchingStrategy, org.springframework.scheduling.TaskScheduler scheduler)
      Create an instance with the supplied parameters.
      Parameters:
      connectionFactory - the connection factory.
      batchingStrategy - the batching strategy.
      scheduler - the scheduler.
      Since:
      2.2
  • Method Details

    • send

      public void send(String exchange, String routingKey, org.springframework.amqp.core.Message message, @Nullable CorrelationData correlationData) throws org.springframework.amqp.AmqpException
      Description copied from interface: RabbitOperations
      Send a message to a specific exchange with a specific routing key.
      Specified by:
      send in interface RabbitOperations
      Overrides:
      send in class RabbitTemplate
      Parameters:
      exchange - the name of the exchange
      routingKey - the routing key
      message - a message to send
      correlationData - data to correlate publisher confirms.
      Throws:
      org.springframework.amqp.AmqpException - if there is a problem
    • flush

      public void flush()
      Flush any partial in-progress batches.
    • doStart

      public void doStart()
      Description copied from class: RabbitTemplate
      Perform additional start actions.
      Overrides:
      doStart in class RabbitTemplate
    • doStop

      public void doStop()
      Description copied from class: RabbitTemplate
      Perform additional stop actions.
      Overrides:
      doStop in class RabbitTemplate
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface RabbitOperations
      Overrides:
      isRunning in class RabbitTemplate