ActiveMQ消息类型

ActiveMQ消息类型
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

消息队列的数据类型

a.文本消息

TextMessage textMessage = session.createTextMessage("文本消息");   

b.键值对消息

MapMessage mapMessage = session.createMapMessage();     
 mapMessage.setLong("age", new Long(32));     
 mapMessage.setDouble("sarray", new Double(5867.15));     
 mapMessage.setString("username", "键值对消息");     

c.流消息

StreamMessage streamMessage = session.createStreamMessage();     
streamMessage.writeString("streamMessage流消息");     
streamMessage.writeLong(55); 

d.字节消息

String s = "BytesMessage字节消息";     
BytesMessage bytesMessage = session.createBytesMessage();     
bytesMessage.writeBytes(s.getBytes());    

e.对象消息

1. User user = new User("cjm", "对象消息"); //User对象必须实现Serializable接口 
2. ObjectMessage objectMessage = session.createObjectMessage();     
3. objectMessage.setObject(user);  

在这里插入图片描述

本文来源蹊源的奇思妙想,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/14690

发表评论