Class BatchingRabbitTemplate
- java.lang.Object
-
- org.springframework.amqp.rabbit.connection.RabbitAccessor
-
- org.springframework.amqp.rabbit.core.RabbitTemplate
-
- org.springframework.amqp.rabbit.core.BatchingRabbitTemplate
-
- All Implemented Interfaces:
AmqpTemplate
,MessageListener
,PublisherCallbackChannel.Listener
,RabbitOperations
,ChannelAwareMessageListener
,ListenerContainerAware
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,Lifecycle
public class BatchingRabbitTemplate extends RabbitTemplate
ARabbitTemplate
that permits batching individual messages into a larger message. Allsend()
methods (exceptsend(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
- Author:
- Gary Russell
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.springframework.amqp.rabbit.core.RabbitTemplate
RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback, RabbitTemplate.ReturnsCallback, RabbitTemplate.TemplateConsumer
-
Nested classes/interfaces inherited from interface org.springframework.amqp.rabbit.core.RabbitOperations
RabbitOperations.OperationsCallback<T>
-
-
Field Summary
-
Fields inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
logger
-
-
Constructor Summary
Constructors Constructor Description BatchingRabbitTemplate(BatchingStrategy batchingStrategy, TaskScheduler scheduler)
Create an instance with the supplied parameters.BatchingRabbitTemplate(ConnectionFactory connectionFactory, BatchingStrategy batchingStrategy, TaskScheduler scheduler)
Create an instance with the supplied parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doStart()
Perform additional start actions.void
doStop()
Perform additional stop actions.void
flush()
Flush any partial in-progress batches.boolean
isRunning()
void
send(String exchange, String routingKey, Message message, CorrelationData correlationData)
Send a message to a specific exchange with a specific routing key.-
Methods inherited from class org.springframework.amqp.rabbit.core.RabbitTemplate
addAfterReceivePostProcessors, addBeforePublishPostProcessors, addListener, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertMessageIfNecessary, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveRaw, correlationConvertAndSend, destroy, determineConfirmsReturnsCapability, doReceiveNoWait, doSend, doSendAndReceive, doSendAndReceiveWithFixed, doSendAndReceiveWithTemporary, execute, expectedQueueNames, getAfterReceivePostProcessors, getDefaultReceiveQueue, getEncoding, getExchange, getMessageConverter, getMessagePropertiesConverter, getRoutingKey, getUnconfirmed, getUnconfirmedCount, getUUID, handleConfirm, handleReturn, handleReturn, initDefaultStrategies, invoke, isChannelLocallyTransacted, isConfirmListener, isMandatoryFor, isReturnListener, isUsePublisherConnection, nullSafeExchange, nullSafeRoutingKey, onMessage, onMessage, receive, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, removeAfterReceivePostProcessor, removeBeforePublishPostProcessor, replyTimedOut, revoke, send, send, send, send, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendToRabbit, setAfterReceivePostProcessors, setBeanFactory, setBeanName, setBeforePublishPostProcessors, setConfirmCallback, setConnectionFactory, setCorrelationDataPostProcessor, setCorrelationKey, setDefaultReceiveQueue, setEncoding, setExchange, setMandatory, setMandatoryExpression, setMandatoryExpressionString, setMessageConverter, setMessagePropertiesConverter, setNoLocalReplyConsumer, setReceiveConnectionFactorySelectorExpression, setReceiveTimeout, setRecoveryCallback, setReplyAddress, setReplyErrorHandler, setReplyTimeout, setRetryTemplate, setReturnCallback, setReturnsCallback, setRoutingKey, setSendConnectionFactorySelectorExpression, setTaskExecutor, setUseChannelForCorrelation, setUseDirectReplyToContainer, setUsePublisherConnection, setUserCorrelationId, setUserIdExpression, setUserIdExpressionString, setUseTemporaryReplyQueues, start, stop, useDirectReplyTo, waitForConfirms, waitForConfirmsOrDie
-
Methods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
onMessageBatch
-
Methods inherited from interface org.springframework.amqp.core.MessageListener
containerAckMode, isAsyncReplies, onMessageBatch
-
Methods inherited from interface org.springframework.amqp.rabbit.core.RabbitOperations
convertSendAndReceiveAsType, getConnectionFactory, invoke
-
-
-
-
Constructor Detail
-
BatchingRabbitTemplate
public BatchingRabbitTemplate(BatchingStrategy batchingStrategy, TaskScheduler scheduler)
Create an instance with the supplied parameters.- Parameters:
batchingStrategy
- the batching strategy.scheduler
- the scheduler.
-
BatchingRabbitTemplate
public BatchingRabbitTemplate(ConnectionFactory connectionFactory, BatchingStrategy batchingStrategy, 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 Detail
-
send
public void send(String exchange, String routingKey, Message message, CorrelationData correlationData) throws AmqpException
Description copied from interface:RabbitOperations
Send a message to a specific exchange with a specific routing key.- Specified by:
send
in interfaceRabbitOperations
- Overrides:
send
in classRabbitTemplate
- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
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 classRabbitTemplate
-
doStop
public void doStop()
Description copied from class:RabbitTemplate
Perform additional stop actions.- Overrides:
doStop
in classRabbitTemplate
-
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceRabbitOperations
- Overrides:
isRunning
in classRabbitTemplate
-
-