new
new String[] { "classpath:/conf/applicationContext_jms.xml"
JmsTemplate template = (JmsTemplate) applicationContext
"jmsTemplate");
//队列消息
Destination destinationQueue = (Destination) applicationContext
"destinationQueue");
//主题消息
Destination destinationTopic = (Destination) applicationContext
"destinationTopic");
"will wait:" + template.getReceiveTimeout()+ " seconds for message");
TextMessage textMsg = (TextMessage) template.receive(destinationQueue);
try{
// 消息 header 中常有的 属性定义
"消息编码:"
"目标对象:"
"消息模式:" + textMsg.getJMSDeliveryMode()); // 消息的模式 分为持久模式和非持久模式, 默认是 非持久的模式(2)
long
new
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String temp = f.format(date);
"消息发送时间:"
"消息失效时间:" + textMsg.getJMSExpiration()); // 这里是一个 整型值 0 表示 该消息永远不会过期
"消息优先级:" + textMsg.getJMSPriority()); // 优先级 0~9, 0 表示最低
"关联编码:"
"回复消息的地址:" + textMsg.getJMSReplyTo()); // 回复消息的地址(Destination类型),由发送者设定
"消息类型:" + textMsg.getJMSType()); // jms 不使用该字段, 一般类型是由 用户自己定义
"是否签收过:" + textMsg.getJMSRedelivered()); // 如果是 真 ,表示客户端收到过该消息,但是并没有签收
// 消息属性 (properties)
"用户编码:" + textMsg.getStringProperty("JMSXUserID"));
"应用程序编码:" + textMsg.getStringProperty("JMSXApp1ID"));
"已经尝试发送消息的次数:" + textMsg.getStringProperty("JMSXDeliveryCount"));
// 消息体(body) 中传递的内容
"消息内容:"
catch(JMSException e){
e.printStackTrace();
catch(Exception e){
e.printStackTrace();
}
//
//取队列消息失败
// TextMessage msgTopic = (TextMessage) template.receive(destinationTopic);
// System.out.println("reviced msg is:" + msgTopic.getText());
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
acivemq如何获取消息 activemq消息类型
ActiveMQ介绍 MQ是消息中间件,是一种在分布式系统中应用程序借以传递消息的媒介,常用的有ActiveMQ,RabbitMQ,kafka。ActiveMQ是Apache下的开源项目,完全支持JMS1.1和J2EE1.4规范的JMS Provider实现。 特点: 1、支持多种语言编写客户端 2、对s
acivemq如何获取消息 AvtiveMQ使用 avtivemq使用 avtivemq怎么用 avtivemq详细使用 -
activemq 获取消息内容 activemq怎么确认消息被消费
ActiveMQ中消息只有在被Broker确认之后才能认为被成功消费。消息的成功消费通常包括三个阶段:1、客户端接收消息,2、客户端处理消息,3、Broker确认消息。其中第2阶段和第3阶段的顺序根据客户端接收消息的方式而定。如果客户端采用receive的方式接收,则阶段2和阶段3是异步执行的,也就是说用户在真正处理消息之时,Broker可能已经确认完了。客户端如果采用listener的方式,则客
activemq 获取消息内容 ActiveMQ消息确认 ActiveMQ源码 ActiveMQ消息消费 ActiveMQ消息删除 -
java activeMQ 获取消息数 activemq jar包
Spring+ActiveMQ 的代码包在这里 点击打开链接 1. 首先下载ActiveMQ服务。本次用的是5.9版本 http://activemq.apache.org/download-archives.html 点击打开链接 标红的activemq-all-5.9.0.jar包是后面代码需要的jar包。2.
java activeMQ 获取消息数 ActiveMQ 消息队列 接收后端参数 前台接收参数