org.jboss.messaging.core
Interface State

All Known Implementing Classes:
ChannelState

public interface State

A channel's state.

Version:
$Revision: 1.23 $ $Id: State.java,v 1.23 2006/04/13 08:57:47 timfox Exp $
Author:
Ovidiu Feodorov, Tim Fox

Method Summary
 boolean acceptReliableMessages()
          A non-recoverable state cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages.
 void acknowledge(Delivery d)
          A Delivery has been acknowledged in a non transactional context.
 void acknowledge(Delivery d, Transaction tx)
          A Delivery has been acknowledged in the presence of a JMS local transaction.
 void addDelivery(Delivery d)
          Add a Delivery to the state
 boolean addReference(MessageReference ref)
          Add a MessageReference to the State
 void addReference(MessageReference ref, Transaction tx)
          This method is called after a new message has arrived at the Channel in the presence of a JMS transaction.
 java.util.List browse(Filter filter)
           
 void cancelDelivery(Delivery d)
          A Delivery has been cancelled.
 void clear()
          Clears non-recoverable state but not persisted state, so a recovery of the channel is possible TODO really?
 java.util.List delivering(Filter filter)
          A list of message references of messages in process of being delivered.
 boolean isRecoverable()
           
 void load()
           
 int messageCount()
          Message amount.
 MessageReference peekFirst()
          Peek the MessageReference at the head of the state without actually removing it
 void removeAll()
          Remove all messages.
 MessageReference removeFirstInMemory()
          Remove the MessageReference at the head of the queue from the state.
 java.util.List undelivered(Filter filter)
          A list of message references of messages that are currently NOT being delivered by the channel.
 

Method Detail

isRecoverable

public boolean isRecoverable()
Returns:
true if the state can guarantee recoverability for reliable messages. Recoverability is not guaranteed for non-reliable messages (and should not be provided by default, for performance reasons), even if the channel is recoverable.

acceptReliableMessages

public boolean acceptReliableMessages()
A non-recoverable state cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages. However, there are situations when discarding a reliable message is acceptable for a specific state instance, so it should be a way to configure the state to do so. A state instance indicates unequivocally whether it accepts reliable messages or not returning true or false as result of this method. The result also applies to deliveries, depending on what kind of message the delivery is related to. A recoverable state must always accept reliable messages, so this method must always return true for a recoverable state.

Returns:
false if the state doesn't accept reliable messages.

addReference

public void addReference(MessageReference ref,
                         Transaction tx)
                  throws java.lang.Throwable
This method is called after a new message has arrived at the Channel in the presence of a JMS transaction. This method updates the transactional state of the Channel to include this message reference. Message delivery is not attempted until the transaction commits.

Parameters:
ref - The MessageReference to add
tx - The JMS local transaction
Throws:
java.lang.Throwable

addReference

public boolean addReference(MessageReference ref)
                     throws java.lang.Throwable
Add a MessageReference to the State

Parameters:
ref - The MessageReference to add
Returns:
true if the addition results in the ref being at the head of the queue. I.e. the queue was empty when the add occurred
Throws:
java.lang.Throwable

addDelivery

public void addDelivery(Delivery d)
                 throws java.lang.Throwable
Add a Delivery to the state

Parameters:
d - The set of delivery instances to add
Throws:
java.lang.Throwable

cancelDelivery

public void cancelDelivery(Delivery d)
                    throws java.lang.Throwable
A Delivery has been cancelled.

Parameters:
d - The delivery to cancel
Throws:
java.lang.Throwable

acknowledge

public void acknowledge(Delivery d,
                        Transaction tx)
                 throws java.lang.Throwable
A Delivery has been acknowledged in the presence of a JMS local transaction.

Parameters:
d - The delivery to acknowledge
tx - The JMS local transaction
Throws:
java.lang.Throwable

acknowledge

public void acknowledge(Delivery d)
                 throws java.lang.Throwable
A Delivery has been acknowledged in a non transactional context.

Parameters:
d - The delivery to acknowledge
Throws:
java.lang.Throwable

removeAll

public void removeAll()
Remove all messages.


removeFirstInMemory

public MessageReference removeFirstInMemory()
                                     throws java.lang.Throwable
Remove the MessageReference at the head of the queue from the state. Note that this operation *does not* remove the MessageReference from RecoverableState - it only removes it from NonRecoverableState.

Returns:
The MessageReference
Throws:
java.lang.Throwable

peekFirst

public MessageReference peekFirst()
                           throws java.lang.Throwable
Peek the MessageReference at the head of the state without actually removing it

Returns:
The MessageReference
Throws:
java.lang.Throwable

delivering

public java.util.List delivering(Filter filter)
A list of message references of messages in process of being delivered.

Returns:
a copy of the internal storage.

undelivered

public java.util.List undelivered(Filter filter)
A list of message references of messages that are currently NOT being delivered by the channel.

Returns:
a copy of the the internal storage.

browse

public java.util.List browse(Filter filter)
Parameters:
filter - - may be null, in which case no filter is applied.
Returns:
a List containing message references of messages whose state is maintained by this State instance. The list includes references of messages in process of being delivered and references of messages for which delivery has not been attempted yet.

clear

public void clear()
Clears non-recoverable state but not persisted state, so a recovery of the channel is possible TODO really?


messageCount

public int messageCount()
Message amount.

Returns:
message amount.

load

public void load()
          throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2006 JBoss Inc. All Rights Reserved.