Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rabbitmq 在Spring AMQP中,我们可以在消费者端设置超时吗_Rabbitmq_Spring Amqp_Spring Rabbit - Fatal编程技术网

Rabbitmq 在Spring AMQP中,我们可以在消费者端设置超时吗

Rabbitmq 在Spring AMQP中,我们可以在消费者端设置超时吗,rabbitmq,spring-amqp,spring-rabbit,Rabbitmq,Spring Amqp,Spring Rabbit,我们可以在Spring AMQP中的用户端设置超时吗 我们有一个用例,AMQP消息到达消费者端 @Named("TestListener") public class TestListener implements MessageListener { @Override public void onMessage(Message message) { // some error logic which got hanged the consumer thr

我们可以在Spring AMQP中的用户端设置超时吗

我们有一个用例,AMQP消息到达消费者端

 @Named("TestListener")
public class TestListener implements MessageListener {

        @Override
    public void onMessage(Message message) {
      // some error logic which got hanged the consumer thread 
    }

有没有办法让使用者(TestListener)代码超时,这样Listener就不会在Spring AMQP中被挂起?如果代码中有线程“卡住”,框架就无能为力了

您可以插入自定义任务执行器、停止容器并关闭执行器(所有线程都将被停止),或者您可以保存线程并以其他方式中断

但是,如果“卡住”的用户代码是不可中断的,即使是中断线程(使用任何技术)也无济于事——例如在一个紧凑的CPU循环中或等待套接字读取

最好的解决方案是修复挂起线程的代码