@@ -0,0 +1,2147 @@
+package com.lance.mq.producer.service;%0A%0Aimport javax.jms.JMSException;%0Aimport javax.jms.Message;%0Aimport javax.jms.Session;%0Aimport javax.jms.TextMessage;%0A%0Aimport org.apache.activemq.command.ActiveMQQueue;%0Aimport org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.jms.core.JmsTemplate;%0Aimport org.springframework.jms.core.MessageCreator;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport com.alibaba.fastjson.JSON;%0Aimport com.lance.mq.producer.info.OrderInfo;%0A%0A@Component%0Apublic class ProducerService %7B%0A%09Logger log = LogManager.getLogger(getClass());%0A%09@Autowired%0A%09private JmsTemplate jmsTemplate;%0A%09@Autowired%0A%09private ActiveMQQueue helloQueue;%0A%09%0A%09/**%0A%09 * %E5%8F%91%E9%80%81Text%E6%B6%88%E6%81%AF%E9%98%9F%E5%88%97%0A%09 * @param message%0A%09 */%0A%09public void sendTextQueueMessage(final String message) %7B%0A%09%09jmsTemplate.send(helloQueue, new MessageCreator()%7B%0A%09%09%09@Override%0A%09%09%09public Message createMessage(Session session) throws JMSException %7B%0A%09%09%09%09return session.createTextMessage(message);%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%09%0A%09/**%0A%09 * %E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF%E5%B9%B6%E5%A4%84%E7%90%86%E6%B6%88%E6%81%AF%E8%BF%94%E5%9B%9E%E5%80%BC%0A%09 * @param message%0A%09 * @throws JMSException %0A%09 */%0A%09public String sendTextQueueMessageAndReceive(final String message) throws JMSException %7B%0A%09%09Message replyMessage = jmsTemplate.sendAndReceive(helloQueue, new MessageCreator()%7B%0A%09%09%09@Override%0A%09%09%09public Message createMessage(Session session) throws JMSException %7B%0A%09%09%09%09return session.createTextMessage(message);%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09log.info(%22sendTextAndReceive: %7B%7D%22, JSON.toJSONString(replyMessage));%0A%09%09TextMessage textMessage = (TextMessage)replyMessage;%0A%09%09return textMessage.getText();%0A%09%7D%0A%09%0A%09/**%0A%09 * %E8%AE%A2%E5%8D%95%E5%85%A5%E9%98%9F%E5%88%97%0A%09 * @param info%0A%09 * @throws JMSException %0A%09 */%0A%09public String sendObjectQueueMessage(final OrderInfo info) throws JMSException %7B%0A%09%09Message message = jmsTemplate.sendAndReceive(helloQueue, new MessageCreator() %7B%0A%09%09%09@Override%0A%09%09%09public Message createMessage(Session session) throws JMSException %7B%0A%09%09%09%09return session.createObjectMessage(info);%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09log.info(%22sendTextAndReceive: %7B%7D%22, JSON.toJSONString(message));%0A%09%09TextMessage textMessage = (TextMessage)message;%0A%09%09return textMessage.getText();%0A%09%7D%0A%7D

add producer service