Spring boot 可以在@JmsListener SpringBoot中选择性禁用队列消费吗?

Spring boot 可以在@JmsListener SpringBoot中选择性禁用队列消费吗?,spring-boot,spring-jms,Spring Boot,Spring Jms,我正在使用SpringBoot和@JmsListener从同一QManager中的多个队列检索IBM MQ消息。到目前为止,我可以得到没有任何问题的消息。但也有可能出现这样的情况,我不得不暂时停止使用其中一个队列中的MSG。它不必是动态的 我没有使用任何自定义ConnectionFactory方法。需要时,我希望在application.properties中进行配置更改,以禁用特定队列消耗并重新启动进程。这可能吗?找不到此场景的任何特定信息。如有任何建议,我们将不胜感激。蒂亚 @Compone

我正在使用SpringBoot和@JmsListener从同一QManager中的多个队列检索IBM MQ消息。到目前为止,我可以得到没有任何问题的消息。但也有可能出现这样的情况,我不得不暂时停止使用其中一个队列中的MSG。它不必是动态的

我没有使用任何自定义ConnectionFactory方法。需要时,我希望在application.properties中进行配置更改,以禁用特定队列消耗并重新启动进程。这可能吗?找不到此场景的任何特定信息。如有任何建议,我们将不胜感激。蒂亚

@Component
public class MyJmsListener {
  @JmsListener(destination = "{ibm.mq.queue.queue01}")
  public void handleQueue01(String message) {
      System.out.println("received: "+message);
  }

  @JmsListener(destination = "{ibm.mq.queue.queue02}")
  public void handleQueue02(String message) {
      System.out.println("received: "+message);
  }
} 


application.properties

ibm.mq.queue.queue01=IBM.QUEUE01
ibm.mq.queue.queue02=IBM.QUEUE02

如果您为每个
@JmsListener
提供一个
id
属性,则可以使用
JmsListenerEndpointRegistry
bean分别启动和停止它们

registry.getListenerContainer(id).stop();