/**
* Receive a message if there is one from a default queue. Returns immediately,
* possibly with a null value.
*
* @return a message or null if there is none waiting
* @throws AmqpException if there is a problem
*/
@Nullable
Message receive() throws AmqpException;
要优化批处理请求的此调用,您可以考虑使用限定范围的操作:
/**
* Invoke the callback and run all operations on the template argument in a dedicated
* thread-bound channel and reliably close the channel afterwards.
* @param action the call back.
* @param <T> the return type.
* @return the result from the
* {@link OperationsCallback#doInRabbit(RabbitOperations operations)}.
* @throws AmqpException if one occurs.
* @since 2.0
*/
@Nullable
default <T> T invoke(OperationsCallback<T> action) throws AmqpException {
1条答案
按热度按时间20jt8wwn1#
为此,您不能使用
@RabbitListener
,而应使用专用API进行按需接收。请参阅RabbitTemplate
:要优化批处理请求的此调用,您可以考虑使用限定范围的操作:
在文档中查看更多信息:https://docs.spring.io/spring-amqp/reference/html/#amqp-template