代码格式调整

This commit is contained in:
lixiangrong 2016-07-18 16:24:01 +08:00
parent 9d919e0354
commit 9a8366ab3e
2 changed files with 21 additions and 28 deletions

View File

@ -11,10 +11,7 @@ import javax.jms.Message;
import javax.jms.Session; import javax.jms.Session;
/** /**
*
* @author liang
* @description 队列消息生产者发送消息到队列 * @description 队列消息生产者发送消息到队列
*
*/ */
@Component("queueSender") @Component("queueSender")
public class QueueSender { public class QueueSender {
@ -36,5 +33,4 @@ public class QueueSender {
} }
}); });
} }
}
}

View File

@ -11,31 +11,28 @@ import javax.jms.Message;
import javax.jms.Session; import javax.jms.Session;
/** /**
* * @description Topic生产者发送消息到Topic
* @author liang
* @description Topic生产者发送消息到Topic
*
*/ */
@Component("topicSender") @Component("topicSender")
public class TopicSender { public class TopicSender {
@Autowired
@Qualifier("jmsTopicTemplate")
private JmsTemplate jmsTemplate;
/**
* 发送一条消息到指定的队列目标
* @param topicName 队列名称
* @param message 消息内容
*/
public void send(String topicName,final String message){
jmsTemplate.send(topicName, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
}
} @Autowired
@Qualifier("jmsTopicTemplate")
private JmsTemplate jmsTemplate;
/**
* 发送一条消息到指定的队列目标
*
* @param topicName 队列名称
* @param message 消息内容
*/
public void send(String topicName, final String message) {
jmsTemplate.send(topicName, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
}
}