Java Reference
In-Depth Information
Extending the JmsGatewaySupport Class
Just like your DAO class can extend JdbcDaoSupport to retrieve a JDBC template, your JMS sender and
receiver classes can also extend JmsGatewaySupport to retrieve a JMS template. You have the following
two options for classes that extend JmsGatewaySupport to create their JMS template:
Inject a JMS connection factory for JmsGatewaySupport to create a JMS template on
it automatically. However, if you do it this way, you won't be able to configure the
details of the JMS template.
Inject a JMS template for JmsGatewaySupport that is created and configured by you.
Of them, the second approach is more suitable if you have to configure the JMS template yourself.
You can delete the private field jmsTemplate and its setter method from both your sender and receiver
classes. When you need access to the JMS template, you just make a call to getJmsTemplate() .
package com.apress.springenterpriserecipes.post;
import org.springframework.jms.core.support.JmsGatewaySupport;
...
public class FrontDeskImpl extends JmsGatewaySupport implements FrontDesk {
...
public void sendMail(final Mail mail) {
getJmsTemplate().send(new MessageCreator() {
...
});
}
}
package com.apress.springenterpriserecipes.post;
...
import org.springframework.jms.core.support.JmsGatewaySupport;
public class BackOfficeImpl extends JmsGatewaySupport implements BackOffice {
public Mail receiveMail() {
MapMessage message = (MapMessage) getJmsTemplate().receive();
...
}
}
7-2. Converting JMS Messages
Problem
Your application receives messages from your message queue, but wants to transform those messages
from the JMS-specific type to a business specific class.
 
Search WWH ::




Custom Search