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
,ApplicationContextAware
,Lifecycle
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
- Author:
- Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.amqp.rabbit.core.RabbitTemplate
RabbitTemplate.ConfirmCallback, 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
ConstructorDescriptionBatchingRabbitTemplate
(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
Modifier and TypeMethodDescriptionvoid
doStart()
Perform additional start actions.void
doStop()
Perform additional stop actions.void
flush()
Flush any partial in-progress batches.boolean
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, addConsumerArg, 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, doReceiveNoWait, doSend, doSendAndReceive, doSendAndReceiveWithFixed, doSendAndReceiveWithTemporary, execute, expectedQueueNames, getAfterReceivePostProcessors, getBeforePublishPostProcessors, getDefaultReceiveQueue, getEncoding, getExchange, getMessageConverter, getMessagePropertiesConverter, getRoutingKey, getUnconfirmed, getUnconfirmedCount, getUUID, handleConfirm, handleReturn, initDefaultStrategies, invoke, isChannelLocallyTransacted, isConfirmListener, isMandatoryFor, isReturnListener, isUsePublisherConnection, logReceived, nullSafeExchange, nullSafeRoutingKey, observeTheSend, onMessage, receive, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, removeAfterReceivePostProcessor, removeBeforePublishPostProcessor, removeConsumerArg, replyTimedOut, revoke, send, send, send, send, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendToRabbit, setAfterReceivePostProcessors, setApplicationContext, setBeanFactory, setBeanName, setBeforePublishPostProcessors, setConfirmCallback, setConnectionFactory, setCorrelationDataPostProcessor, setCorrelationKey, setDefaultReceiveQueue, setEncoding, setExchange, setMandatory, setMandatoryExpression, setMandatoryExpressionString, setMessageConverter, setMessagePropertiesConverter, setNoLocalReplyConsumer, setObservationConvention, setObservationEnabled, setReceiveConnectionFactorySelectorExpression, setReceiveTimeout, setRecoveryCallback, setReplyAddress, setReplyErrorHandler, setReplyTimeout, setRetryTemplate, 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, getObservationRegistry, getTransactionalResourceHolder, isChannelTransacted, obtainObservationRegistry, 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
onMessage, 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 Details
-
BatchingRabbitTemplate
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 Details
-
send
public void send(String exchange, String routingKey, Message message, @Nullable 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
-