如果在RabbitMQ应用程序中抛出异常,我想学习一种简单的方法来请求SpringBoot。
@RabbitListener(queues = TRANSACTION_171_REQUEST_QUEUE, errorHandler = "receiverExceptionHandler" )
public void listen171RequestsQueue(Transaction171Request request) {
try {
Transaction171Response response = null;
send171Response("OK", request.getNumeroFormularioRenach());
} catch (Exception e){
//Requeue message
}
}我的代码行为是使用一条消息,并根据消息发生的情况将它从队列中取出。如果抛出异常,我希望在RabbitMQ中请求消息。
你能帮我一下吗?
我正在使用Java 11开发一个SpringBoot应用程序。
发布于 2022-02-14 16:08:18
RabbitMQ的默认行为是在出现未处理异常时请求。在您的情况下,您可以删除try..catch块,或者在catch块中只需重新抛出异常。
https://stackoverflow.com/questions/71114242
复制相似问题