正如前面的答案所指出的,有必要在工厂设置客户端ID和持久订阅:
@Beanpublic DefaultJmsListenerContainerFactory jmsListenerContainerFactory() { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setConnectionFactory(connectionFactory()); factory.setDestinationResolver(destinationResolver()); factory.setConcurrency("3-10"); factory.setClientID("brokerClientId"); factory.setSubscriptionDurable(true); return factory;}
但这本身并不能将客户端注册为持久订阅者,这是因为
JMSListener需要
containerFactory指定该客户端,否则它将采用默认值:
@JmsListener(destination = "venta.topic",id = "comercial",subscription = "venta.topic",//this was also needed with the same name as the bean abovecontainerFactory = "jmsListenerContainerFactory" )public void receiveMessage(Venta venta) { logger.log(Level.INFO, "RECEIVED : {0}",venta); repository.save(venta);}
值得一提的是,这篇帖子使我意识到自己的错误。
我希望这会帮助别人
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)