Updated indentation and refactored code
This commit is contained in:
parent
d98924b39d
commit
94f258f90c
|
@ -1,6 +1,8 @@
|
||||||
package com.baeldung.spring.jms;
|
package com.baeldung.spring.jms;
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
|
@ -14,8 +16,8 @@ public class SampleJmsMessageSender {
|
||||||
private JmsTemplate jmsTemplate;
|
private JmsTemplate jmsTemplate;
|
||||||
private Queue queue;
|
private Queue queue;
|
||||||
|
|
||||||
public void setConnectionFactory(ConnectionFactory cf) {
|
public void setJmsTemplate(JmsTemplate jmsTemplate) {
|
||||||
this.jmsTemplate = new JmsTemplate(cf);
|
this.jmsTemplate = jmsTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQueue(Queue queue) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue