activemq spring 整合
最近的项目需目需要用到activemq ,看了些资料,自己也写了一个简单的demo
?
Sender用来发消息
Receiver用来接收消息同时他实现了MessageListener接口
?
?
费话不多说,上代码
applicationContext.xml
?
?看完这个,大家估计就都明白了,哥的demo就是这么简单
?
?
?
?
再来个启动
?
import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class SenderTest { public static void main(String[] args) { // TODO 自动生成方法存根 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-jms2.xml"); Sender sender = (Sender) context.getBean("sender"); sender.sendInfo(); System.out.println("send finish"); }}?
因为把sender和reciever 写在了一个demo里,所以一运行起来,就会打印出结果,呵呵