FileDocCategorySizeDatePackage
MessageReplierBean.javaAPI DocJBoss 4.2.12974Fri Jul 13 20:52:44 BST 2007org.jboss.ejb3.test.appclient

MessageReplierBean

public class MessageReplierBean extends Object implements javax.jms.MessageListener
This message bean will just reply the message.
author
Carlo de Wolf
version
$Revision: $

Fields Summary
private static final Logger
log
private javax.jms.ConnectionFactory
connectionFactory
Constructors Summary
Methods Summary
public voidonMessage(javax.jms.Message message)

      try
      {
         if(message.getJMSReplyTo() != null)
         {
            Destination destination = message.getJMSReplyTo();
            
            Connection conn = connectionFactory.createConnection();
            try
            {
               Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
               MessageProducer producer = session.createProducer(destination);
               producer.send(destination, message);
               producer.close();
               session.close();
            }
            finally
            {
               conn.close();
            }
         }
         else
            log.info("no reply to specified");
      }
      catch(JMSException e)
      {
         throw new EJBException(e);
      }