Java Reference
In-Depth Information
In the front desk subsystem's bean configuration file, you declare a JMS template that refers to the
JMS connection factory for opening connections. Then you inject this template as well as the message
destination into your front desk bean.
<beans ...>
<bean id="connectionFactory"
<property name="brokerURL" value=" tcp://localhost:61616" />
<bean id="mailDestination"
<constructor-arg value="mail.queue" />
<bean id="jmsTemplate"
<property name="connectionFactory" ref="connectionFactory" />
<bean id="frontDesk"
<property name="destination" ref="mailDestination" />
<property name="jmsTemplate" ref="jmsTemplate" />
To receive a JMS message with a JMS template, you call the receive() method by providing a
message destination. This method returns a JMS message whose type is the base JMS message type,
an interface, javax.jms.Message , so you have to cast it into proper type before further processing.
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import org.springframework.jms.core.JmsTemplate;
public class BackOfficeImpl implements BackOffice {
private JmsTemplate jmsTemplate;
private Destination destination;
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
Search WWH ::

Custom Search