FileDocCategorySizeDatePackage
JmsMessageConsumer.javaAPI DocJBoss 4.2.15030Fri Jul 13 21:01:16 BST 2007org.jboss.resource.adapter.jms

JmsMessageConsumer

public class JmsMessageConsumer extends Object implements javax.jms.MessageConsumer
A wrapper for a message consumer
author
Adrian Brock
version
$Revision: 57189 $

Fields Summary
private static final Logger
log
javax.jms.MessageConsumer
consumer
The wrapped message consumer
JmsSession
session
The session for this consumer
private boolean
trace
Whether trace is enabled
Constructors Summary
public JmsMessageConsumer(javax.jms.MessageConsumer consumer, JmsSession session)
Create a new wrapper

param
consumer the consumer
param
session the session


                    
       
   
      this.consumer = consumer;
      this.session = session;
      
      if (trace)
         log.trace("new JmsMessageConsumer " + this + " consumer=" + consumer + " session=" + session);
   
Methods Summary
public voidclose()

      if (trace)
         log.trace("close " + this);
      try
      {
         closeConsumer();
      }
      finally
      {
         session.removeConsumer(this);
      }
   
voidcloseConsumer()

      consumer.close();
   
public javax.jms.MessageListenergetMessageListener()

      session.checkStrict();
      return consumer.getMessageListener();
   
public java.lang.StringgetMessageSelector()

      return consumer.getMessageSelector();
   
public javax.jms.Messagereceive()

      if (trace)
         log.trace("receive " + this);
      Message message = consumer.receive();
      if (trace)
         log.trace("received " + this + " result=" + message);
      if (message == null)
         return null;
      else
         return wrapMessage(message);
   
public javax.jms.Messagereceive(long timeout)

      if (trace)
         log.trace("receive " + this + " timeout=" + timeout);
      Message message = consumer.receive(timeout);
      if (trace)
         log.trace("received " + this + " result=" + message);
      if (message == null)
         return null;
      else
         return wrapMessage(message);
   
public javax.jms.MessagereceiveNoWait()

      if (trace)
         log.trace("receiveNoWait " + this);
      Message message = consumer.receiveNoWait();
      if (trace)
         log.trace("received " + this + " result=" + message);
      if (message == null)
         return null;
      else
         return wrapMessage(message);
   
public voidsetMessageListener(javax.jms.MessageListener listener)

      session.checkStrict();
      if (listener == null)
         consumer.setMessageListener(null);
      else
         consumer.setMessageListener(wrapMessageListener(listener));
   
javax.jms.MessagewrapMessage(javax.jms.Message message)

      if (message instanceof BytesMessage)
         return new JmsBytesMessage((BytesMessage) message, session);
      else if (message instanceof MapMessage)
         return new JmsMapMessage((MapMessage) message, session);
      else if (message instanceof ObjectMessage)
         return new JmsObjectMessage((ObjectMessage) message, session);
      else if (message instanceof StreamMessage)
         return new JmsStreamMessage((StreamMessage) message, session);
      else if (message instanceof TextMessage)
         return new JmsTextMessage((TextMessage) message, session);
      return new JmsMessage(message, session);
   
javax.jms.MessageListenerwrapMessageListener(javax.jms.MessageListener listener)

      return new JmsMessageListener(listener, this);