activenq整合spring之队列消费者

@Test
public void testJmsTemplateByConsumer(){

    ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");

    JmsTemplate jmsTemplate = (JmsTemplate) ioc.getBean("jmsTemplate");

    String returnValue = (String) jmsTemplate.receiveAndConvert();

    System.out.println(returnValue);
}

   上面是queue,如果想要换成topic,直接在ioc配置文件切换就行。

posted @ 2020-11-29 22:40  爱编程DE文兄  阅读(113)  评论(0编辑  收藏  举报