flex.messaging.services.messaging.adapters
Class JMSConsumer

java.lang.Object
  extended by flex.messaging.services.messaging.adapters.JMSProxy
      extended by flex.messaging.services.messaging.adapters.JMSConsumer
All Implemented Interfaces:
javax.jms.ExceptionListener
Direct Known Subclasses:
JMSQueueConsumer

public abstract class JMSConsumer
extends JMSProxy
implements javax.jms.ExceptionListener

A JMSProxy subclass for javax.jms.MessageConsumer instance.


Nested Class Summary
 
Nested classes/interfaces inherited from class flex.messaging.services.messaging.adapters.JMSProxy
JMSProxy.ConnectionCredentials
 
Constructor Summary
JMSConsumer()
           
 
Method Summary
 void addJMSExceptionListener(JMSExceptionListener listener)
          Adds a JMS exception listener.
 void addJMSMessageListener(JMSMessageListener listener)
          Adds a JMS message listener.
 flex.messaging.services.messaging.adapters.MessageReceiver getMessageReceiver()
          Returns the MessageReceiver used by the consumer to retrieve JMS messages.
 String getSelectorExpression()
          Returns the selector expression used when the underlying javax.jms.MessageConsumer is created.
 void onException(javax.jms.JMSException exception)
          Implementation of javax.jms.ExceptionListener.onException.
 void onMessage(javax.jms.Message jmsMessage)
          Acnowledges the receipt of the message to the JMS server and passes the message to registered JMS message listeners.
 javax.jms.Message receive()
          Receive the next message from the underlying MessageConsumer or wait indefinetely until a message arrives if there is no message.
 javax.jms.Message receive(long timeout)
          Receive the next message from the underlying MessageConsumer within the specified timeout interval.
 javax.jms.Message receiveNoWait()
          Receive the new message from the underlying MessageConsumer with no wait.
 void removeJMSExceptionListener(JMSExceptionListener listener)
          Removes a JMS exception listener.
 void removeJMSMessageListener(JMSMessageListener listener)
          Removes a JMS message listener.
 javax.jms.MessageListener setMessageListener(javax.jms.MessageListener listener)
          Sets the message listener of the underlying MessageConsumer.
 void setMessageReceiver(flex.messaging.services.messaging.adapters.MessageReceiver messageReceiver)
          Sets the MessageReceiver used by the consumer to retrieve JMS messages.
 void setSelectorExpression(String selectorExpression)
          Sets the selector expression used when the underlying javax.jms.MessageConsumer is created.
 void start()
          Starts the JMSConsumer.
 void stop()
          Stops the JMSConsumer by stopping its associated receiver adapter and closing the underlying MessageConsumer.
 void stop(boolean unsubscribe)
          Stops the JMSConsumer and unsubscribes a durable subscription if one exists.
 
Methods inherited from class flex.messaging.services.messaging.adapters.JMSProxy
getAcknowledgeMode, getConnectionCredentials, getConnectionFactoryName, getDestinationJndiName, getInitialContextEnvironment, initialize, setAcknowledgeMode, setConnectionCredentials, setConnectionFactoryName, setDestinationJndiName, setInitialContextEnvironment
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSConsumer

public JMSConsumer()
Method Detail

start

public void start()
           throws NamingException,
                  javax.jms.JMSException
Starts the JMSConsumer. Subclasses should call super.start.

Overrides:
start in class JMSProxy
Throws:
NamingException - The thrown naming exception.
javax.jms.JMSException - The thrown JMS exception.

stop

public void stop()
Stops the JMSConsumer by stopping its associated receiver adapter and closing the underlying MessageConsumer. It then calls JMSProxy.close for session and connection closure.

Overrides:
stop in class JMSProxy

stop

public void stop(boolean unsubscribe)
Stops the JMSConsumer and unsubscribes a durable subscription if one exists. By default this method delegates to stop() and doesn't remove a durable subscription.

Parameters:
unsubscribe - Determines whether to unsubscribe a durable subscription if one exists, or not.

addJMSMessageListener

public void addJMSMessageListener(JMSMessageListener listener)
Adds a JMS message listener.

Parameters:
listener - The listener to add.
See Also:
JMSMessageListener

removeJMSMessageListener

public void removeJMSMessageListener(JMSMessageListener listener)
Removes a JMS message listener.

Parameters:
listener - The listener to remove.
See Also:
JMSMessageListener

addJMSExceptionListener

public void addJMSExceptionListener(JMSExceptionListener listener)
Adds a JMS exception listener.

Parameters:
listener - The listener to add.
See Also:
JMSExceptionListener

removeJMSExceptionListener

public void removeJMSExceptionListener(JMSExceptionListener listener)
Removes a JMS exception listener.

Parameters:
listener - The listener to remove.
See Also:
JMSExceptionListener

setMessageListener

public javax.jms.MessageListener setMessageListener(javax.jms.MessageListener listener)
                                             throws javax.jms.JMSException
Sets the message listener of the underlying MessageConsumer. This method is not meant to be directly called as it is used internally by MessageReceivers that need to perform async message delivery. Any future custom MessageReceiver implementations can use this method to set themselves as MessageListeners to the underlying MessageConsumer.

Parameters:
listener - Message listener to set on the underlying MessageConsumer.
Returns:
The old message listener associated with the MessageConsumer.
Throws:
javax.jms.JMSException - The thrown JMS exception.

getMessageReceiver

public flex.messaging.services.messaging.adapters.MessageReceiver getMessageReceiver()
Returns the MessageReceiver used by the consumer to retrieve JMS messages.

Returns:
The MessageReceiver used.

setMessageReceiver

public void setMessageReceiver(flex.messaging.services.messaging.adapters.MessageReceiver messageReceiver)
Sets the MessageReceiver used by the consumer to retrieve JMS messages. This property should not change after startup.

Parameters:
messageReceiver - The MessageReceiver used.

getSelectorExpression

public String getSelectorExpression()
Returns the selector expression used when the underlying javax.jms.MessageConsumer is created.

Returns:
The selector expression.

setSelectorExpression

public void setSelectorExpression(String selectorExpression)
Sets the selector expression used when the underlying javax.jms.MessageConsumer is created. This property should not change after startup.

Parameters:
selectorExpression - The selector expression.

onException

public void onException(javax.jms.JMSException exception)
Implementation of javax.jms.ExceptionListener.onException. Dispatches the JMS exception to registered JMS exception listeners.

Specified by:
onException in interface javax.jms.ExceptionListener
Parameters:
exception - The thrown JMS exception.

onMessage

public void onMessage(javax.jms.Message jmsMessage)
Acnowledges the receipt of the message to the JMS server and passes the message to registered JMS message listeners.

Parameters:
jmsMessage - The new JMS message to acknowledge and dispatch.

receive

public javax.jms.Message receive()
                          throws javax.jms.JMSException
Receive the next message from the underlying MessageConsumer or wait indefinetely until a message arrives if there is no message.

Returns:
The received JMS message.
Throws:
javax.jms.JMSException - The thrown JMS exception.

receive

public javax.jms.Message receive(long timeout)
                          throws javax.jms.JMSException
Receive the next message from the underlying MessageConsumer within the specified timeout interval.

Parameters:
timeout - The number of milliseconds to wait for a new message.
Throws:
javax.jms.JMSException - The thrown JMS exception.

receiveNoWait

public javax.jms.Message receiveNoWait()
                                throws javax.jms.JMSException
Receive the new message from the underlying MessageConsumer with no wait.

Returns:
The received JMS message.
Throws:
javax.jms.JMSException - The thrown JMS exception.


Copyright © 2008 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/services/messaging/adapters/JMSConsumer.html