Sending a message to JMS Queue
Here is some code to send a message to a JMS queue using Spring:
ConnectionFactory connectionFactory = // Look up connectionfactory from JNDI
Queue queue = // Look up distributed queue from JNDI
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
jmsTemplate.send(queue, new MessageCreator() {
public Message createMessage(Session session) throws JMSException
{
ObjectMessage message = session.createObjectMessage();
// Set the message content
message.setObject(new Object());
return message;
} }
);
Categories: Uncategorized