标签:消息主体
首先对象必须是可序列化的实现Serializable接口
这里HashMap为例
producer端
HashMap<String,String> map=new HashMap<String, String>(); map.put("param1", "姓名"); map.put("param2", "年龄"); map.put("param3", "性别"); ObjectMessage message=session.createObjectMessage(map); System.out.println(map); messageProducer.send(message);
consumer端
while(true){ ObjectMessage objectMessage=(ObjectMessage)messageConsumer.receive(1000); System.out.println(objectMessage); if(objectMessage!=null){ System.out.println("收到的消息:"+objectMessage.getObject()); }else{ continue; } }
参考文章:
http://blog.csdn.net/madun/article/details/21800999
本文出自 “一无所有-天行者” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1686740
标签:消息主体
原文地址:http://tianxingzhe.blog.51cto.com/3390077/1686740