Java Reference
In-Depth Information
<bean id="backOffice"
class="com.apress.springenterpriserecipes.post.BackOfficeImpl">
<property name="jmsTemplate" ref="jmsTemplate" />
</bean>
</beans>
With the default destination specified for a JMS template, you can delete the setter method for a
message destination from your message sender and receiver classes. Now when you call the send() and
receive() methods, you no longer need to specify a message destination.
package com.apress.springenterpriserecipes.post;
...
import org.springframework.jms.core.MessageCreator;
public class FrontDeskImpl implements FrontDesk {
...
public void sendMail(final Mail mail) {
jmsTemplate.send(new MessageCreator() {
...
});
}
}
package com.apress.springenterpriserecipes.post;
...
import javax.jms.MapMessage;
public class BackOfficeImpl implements BackOffice {
...
public Mail receiveMail() {
MapMessage message = (MapMessage) jmsTemplate.receive();
...
}
}
Instead of specifying an instance of the Destination interface for a JMS template, you can specify
the destination name to let the JMS template resolve it for you, so you can delete the Destination
object's declaration from both bean configuration files.
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
...
<property name="defaultDestinationName" value="mail.queue" />
</bean>
Search WWH ::




Custom Search