Updated indentation and refactored code

This commit is contained in:
Kiran 2016-10-09 13:53:20 -04:00 committed by GitHub
parent d98924b39d
commit 94f258f90c
1 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,8 @@
package com.baeldung.spring.jms;
import javax.jms.ConnectionFactory;
import java.util.HashMap;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
@ -14,8 +16,8 @@ public class SampleJmsMessageSender {
private JmsTemplate jmsTemplate;
private Queue queue;
public void setConnectionFactory(ConnectionFactory cf) {
this.jmsTemplate = new JmsTemplate(cf);
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
public void setQueue(Queue queue) {
@ -29,4 +31,12 @@ public class SampleJmsMessageSender {
}
});
}
public void sendMessage(final Employee employee) {
System.out.println("Jms Message Sender : " + employee);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", employee.getName());
map.put("age", employee.getAge());
this.jmsTemplate.convertAndSend(map);
}
}