org.huihoo.jfox.ms.jms.base
Class MessageConsumerImpl

java.lang.Object
  extended byorg.huihoo.jfox.ms.jms.base.MessageConsumerImpl
All Implemented Interfaces:
javax.jms.MessageConsumer
Direct Known Subclasses:
QueueReceiverImpl, TopicSubscriberImpl

public abstract class MessageConsumerImpl
extends java.lang.Object
implements javax.jms.MessageConsumer

This class implements the JMS message producer. A client uses a MessageConsumer object to receive messages from a destination. A MessageConsumer object is created by passing a Destination object to a message-consumer creation method supplied by a session.

Version:
Revision: 1.1 Date: 2003-05-20 21:36:14
Author:
Peter.Cheng

Constructor Summary
MessageConsumerImpl(SessionImpl session, java.lang.String messageSelector)
           
 
Method Summary
 void close()
          Closes the message consumer.
 javax.jms.MessageListener getMessageListener()
          Gets the message consumer's MessageListener.
 java.lang.String getMessageSelector()
          Gets this message consumer's message selector expression.
 boolean isClosed()
          Indicates the status of this message consumer.
 javax.jms.Message receive()
          Receives the next message produced for this message consumer.
 javax.jms.Message receive(long timeout)
          Receives the next message that arrives within the specified timeout interval.
 javax.jms.Message receiveNoWait()
          Receives the next message if one is immediately available.Do not wait for a message to be recevied.
 void setMessageListener(javax.jms.MessageListener listener)
          ets the message consumer's MessageListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageConsumerImpl

public MessageConsumerImpl(SessionImpl session,
                           java.lang.String messageSelector)
Method Detail

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Gets the message consumer's MessageListener.

Specified by:
getMessageListener in interface javax.jms.MessageConsumer
Returns:
the listener for the message consumer, or null if no listener is set
Throws:
javax.jms.JMSException

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
                        throws javax.jms.JMSException
ets the message consumer's MessageListener.

Setting the message listener to null is the equivalent of unsetting the message listener for the message consumer.

The effect of calling MessageConsumer.setMessageListener while messages are being consumed by an existing listener or the consumer is being used to consume messages synchronously is undefined.

Specified by:
setMessageListener in interface javax.jms.MessageConsumer
Parameters:
listener - the listener to which the messages are to be delivered
Throws:
javax.jms.JMSException

getMessageSelector

public java.lang.String getMessageSelector()
                                    throws javax.jms.JMSException
Gets this message consumer's message selector expression.

Specified by:
getMessageSelector in interface javax.jms.MessageConsumer
Returns:
this message consumer's message selector, or null if no message selector exists for the message consumer (that is, if the message selector was not set or was set to null or the empty string)
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive()
                          throws javax.jms.JMSException
Receives the next message produced for this message consumer. If no message is available, this call will block until a message can be received.

This call blocks indefinitely until a message is produced or until this message consumer is closed.

If this receive is done within a transaction, the consumer retains the message until the transaction commits.

Specified by:
receive in interface javax.jms.MessageConsumer
Returns:
the next message produced for this message consumer, or null if this message consumer is concurrently closed
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive(long timeout)
                          throws javax.jms.JMSException
Receives the next message that arrives within the specified timeout interval.

This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A timeout of zero never expires, and the call blocks indefinitely.

Specified by:
receive in interface javax.jms.MessageConsumer
Parameters:
timeout - the timeout value (in milliseconds)
Returns:
the next message produced for this message consumer, or null if the timeout expires or this message consumer is concurrently closed
Throws:
javax.jms.JMSException

receiveNoWait

public javax.jms.Message receiveNoWait()
                                throws javax.jms.JMSException
Receives the next message if one is immediately available.Do not wait for a message to be recevied.

Specified by:
receiveNoWait in interface javax.jms.MessageConsumer
Returns:
the next message produced for this message consumer, or null if one is not available
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Closes the message consumer.

Since a provider may allocate some resources on behalf of a MessageConsumer outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

This call blocks until a receive or message listener in progress has completed. A blocked message consumer receive call

Specified by:
close in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

isClosed

public boolean isClosed()
Indicates the status of this message consumer.

Returns:
true if the message consumer is closed


Copyright © 2002-2003 Open Enterprise Foundation. All Rights Reserved.