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());