org.codehaus.activemq.service
Interface Subscription

All Known Implementing Classes:
SubscriptionImpl

public interface Subscription

A Subscription holds messages to be dispatched to a a Client Consumer

Version:
$Revision: 1.15 $

Method Summary
 void addMessage(MessageContainer container, ActiveMQMessage message)
          If the Subscription is a target for the message, the subscription will add a reference to the message and register an interest in the message to the container
 void clear()
          Called when the Subscription is discarded
 String getClientId()
           
 String getConsumerId()
           
 int getConsumerNumber()
           
 ActiveMQDestination getDestination()
           
 MessageIdentity getLastMessageIdentity()
          Retreives the messageIdentity of the last message sent to this Queue based Subscription
 ActiveMQMessage[] getMessagesToDispatch()
          Retrieve messages to dispatch
 String getPersistentKey()
          Returns the persistent key used to uniquely identify this durable topic subscription
 String getSelector()
           
 String getSubscriberName()
           
 SubscriberEntry getSubscriptionEntry()
          Lazily creates the persistent entry representation of this subscription
 boolean isActive()
           
 boolean isAtPrefetchLimit()
          Indicates the Subscription it's reached it's pre-fetch limit
 boolean isBrowser()
          Indicates the consumer is a browser only
 boolean isDurableTopic()
          Indicates the Consumer is a Durable Subscriber
 boolean isReadyToDispatch()
          Indicates if this Subscription has more messages to send to the Consumer
 boolean isSameDurableSubscription(ConsumerInfo info)
          Checks if this subscription is a duplicate durable subscription of the given consumer info
 boolean isTarget(ActiveMQMessage message)
          determines if the Subscription is interested in the message
 boolean isWildcard()
           
 void messageConsumed(MessageAck ack)
          Indicates a message has been delivered to a MessageConsumer which is typically called for topic based subscriptions
 void onAcknowledgeTransactedMessageBeforeCommit(MessageAck ack)
          We have not yet committed and so the message acknowledgement has not really occurred yet but we need to let the dispatcher know that we can commence dispatching more messages to the client.
 void redeliverMessage(MessageContainer container, MessageAck ack)
          Forces the given message to be redelivered
 void reset()
          Called when an active message consumer has closed.
 void setActive(boolean newActive)
          set the state of the Subscription
 void setActiveConsumer(BrokerClient client, ConsumerInfo info)
          Set the active consumer info
 void setLastMessageIdentifier(MessageIdentity messageIdentity)
          Used for a Queue based Subscription to set the last acknowledged message ID
 

Method Detail

setActiveConsumer

public void setActiveConsumer(BrokerClient client,
                              ConsumerInfo info)
Set the active consumer info

Parameters:
client -
info -

clear

public void clear()
           throws JMSException
Called when the Subscription is discarded

Throws:
JMSException

reset

public void reset()
           throws JMSException
Called when an active message consumer has closed.

Throws:
JMSException

getClientId

public String getClientId()
Returns:
Returns the clientId.

getSubscriberName

public String getSubscriberName()
Returns:
Returns the subscriberName.

getDestination

public ActiveMQDestination getDestination()
Returns:
Returns the destination.

getSelector

public String getSelector()
Returns:
Returns the selector.

isActive

public boolean isActive()
Returns:
Returns true if an active message consumer is associated with this

setActive

public void setActive(boolean newActive)
               throws JMSException
set the state of the Subscription

Parameters:
newActive -
Throws:
JMSException

getConsumerNumber

public int getConsumerNumber()
Returns:
Returns the consumerNumber.

getConsumerId

public String getConsumerId()
Returns:
the consumer Id for the active consumer

isTarget

public boolean isTarget(ActiveMQMessage message)
                 throws JMSException
determines if the Subscription is interested in the message

Parameters:
message -
Returns:
Throws:
JMSException

addMessage

public void addMessage(MessageContainer container,
                       ActiveMQMessage message)
                throws JMSException
If the Subscription is a target for the message, the subscription will add a reference to the message and register an interest in the message to the container

Parameters:
container -
message -
Throws:
JMSException

messageConsumed

public void messageConsumed(MessageAck ack)
                     throws JMSException
Indicates a message has been delivered to a MessageConsumer which is typically called for topic based subscriptions

Parameters:
ack -
Throws:
JMSException

redeliverMessage

public void redeliverMessage(MessageContainer container,
                             MessageAck ack)
                      throws JMSException
Forces the given message to be redelivered

Parameters:
container -
ack -
Throws:
JMSException

getMessagesToDispatch

public ActiveMQMessage[] getMessagesToDispatch()
                                        throws JMSException
Retrieve messages to dispatch

Returns:
Throws:
JMSException

isReadyToDispatch

public boolean isReadyToDispatch()
                          throws JMSException
Indicates if this Subscription has more messages to send to the Consumer

Returns:
true if more messages available to dispatch
Throws:
JMSException

isAtPrefetchLimit

public boolean isAtPrefetchLimit()
                          throws JMSException
Indicates the Subscription it's reached it's pre-fetch limit

Returns:
true/false
Throws:
JMSException

isDurableTopic

public boolean isDurableTopic()
                       throws JMSException
Indicates the Consumer is a Durable Subscriber

Returns:
Throws:
JMSException

isBrowser

public boolean isBrowser()
                  throws JMSException
Indicates the consumer is a browser only

Returns:
true if a Browser
Throws:
JMSException

getLastMessageIdentity

public MessageIdentity getLastMessageIdentity()
                                       throws JMSException
Retreives the messageIdentity of the last message sent to this Queue based Subscription

Returns:
the messageId of the last message or null
Throws:
JMSException

setLastMessageIdentifier

public void setLastMessageIdentifier(MessageIdentity messageIdentity)
                              throws JMSException
Used for a Queue based Subscription to set the last acknowledged message ID

Parameters:
messageIdentity -
Throws:
JMSException

isWildcard

public boolean isWildcard()

getPersistentKey

public String getPersistentKey()
Returns the persistent key used to uniquely identify this durable topic subscription

Returns:

isSameDurableSubscription

public boolean isSameDurableSubscription(ConsumerInfo info)
                                  throws JMSException
Checks if this subscription is a duplicate durable subscription of the given consumer info

Parameters:
info -
Returns:
true if this subscription is a durable topic subscription and the clientID and consumer names match
Throws:
JMSException

onAcknowledgeTransactedMessageBeforeCommit

public void onAcknowledgeTransactedMessageBeforeCommit(MessageAck ack)
                                                throws JMSException
We have not yet committed and so the message acknowledgement has not really occurred yet but we need to let the dispatcher know that we can commence dispatching more messages to the client. This is so that we can have a prefetch value of 1 yet we can still consume 1000 messages inside a transaction, with all the acks coming after the commit() on the client.

Parameters:
ack -
Throws:
JMSException

getSubscriptionEntry

public SubscriberEntry getSubscriptionEntry()
Lazily creates the persistent entry representation of this subscription



Copyright © 2004 Protique, Ltd.. All Rights Reserved.