org.jboss.messaging.core
Interface Channel

All Superinterfaces:
DeliveryObserver, Distributor, Receiver
All Known Implementing Classes:
ChannelSupport

public interface Channel
extends DeliveryObserver, Receiver, Distributor

A Channel is a transactional, reliable message delivery mechanism that forwards a message from a sender to one or more receivers. The channel tries to deliver a message synchronously, if possible, and stores the message for re-delivery if synchronous delivery is not possible. A channel implementation may chose to be transactional, reliable or none of the above. A simple channel implementation may not able to accept messages/acknowledgments transactionally, and may not guarantee recoverability in case of failure. A transactional channel must be able to guarantee atomicity when accepting messages/acknowledgments. A reliable channel must be able to guarantee atomicity and recoverability in case of failure. However, recoverability is guaranteed only for reliable messages. For non-reliable message, the channel will do its best effort.

Version:
$Revision: 1174 $ $Id: Channel.java 1174 2006-08-02 14:14:32Z timfox $
Author:
Ovidiu Feodorov, Tim Fox

Method Summary
 boolean acceptReliableMessages()
          A non-recoverable channel cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages.
 java.util.List browse()
           
 java.util.List browse(Filter filter)
           
 void clear()
          Clears non-recoverable state but not persisted state, so a recovery of the channel is possible TODO really?
 void close()
          Close the channel
 void deliver(boolean synchronous)
          Delivers as many references as possible to it's router until no more deliveries are returned
 java.util.List delivering(Filter filter)
          Get a list of message references of messages in the process of being delivered, subject to the filter
 long getChannelID()
           
 boolean isRecoverable()
           
 void load()
          Load the channel state from storage
 int messageCount()
          Message amount.
 void removeAllReferences()
          Remove all the references in the channel
 java.util.List undelivered(Filter filter)
          Get a list of message references of messages not in the process of being delivered, subject to the filter
 
Methods inherited from interface org.jboss.messaging.core.DeliveryObserver
acknowledge, cancel
 
Methods inherited from interface org.jboss.messaging.core.Receiver
handle
 
Methods inherited from interface org.jboss.messaging.core.Distributor
add, contains, iterator, remove
 

Method Detail

getChannelID

public long getChannelID()
Returns:
the unique ID of the channel

isRecoverable

public boolean isRecoverable()
Returns:
true if the channel 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 channel 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 instance of a channel, so it should be a way to configure the channel to do so. A channel indicates unequivocally whether it accepts reliable messages or not returning true or false as result of this method. A recoverable channel must always accept reliable messages, so this method must always return true for a recoverable channel.

Returns:
false if the channel doesn't accept reliable messages.
See Also:
State#acceptReliableMessages()

browse

public java.util.List browse()
Returns:
a List containing messages being held by the channel. The list includes messages in process of being delivered and messages for which delivery hasn't been attempted yet.

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.

deliver

public void deliver(boolean synchronous)
Delivers as many references as possible to it's router until no more deliveries are returned


close

public void close()
Close the channel


delivering

public java.util.List delivering(Filter filter)
Get a list of message references of messages in the process of being delivered, subject to the filter

Parameters:
filter -
Returns:
the list

undelivered

public java.util.List undelivered(Filter filter)
Get a list of message references of messages not in the process of being delivered, subject to the filter

Parameters:
filter -
Returns:
the list

clear

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

Specified by:
clear in interface Distributor

messageCount

public int messageCount()
Message amount.

Returns:
message amount.

load

public void load()
          throws java.lang.Exception
Load the channel state from storage

Throws:
java.lang.Exception

removeAllReferences

public void removeAllReferences()
                         throws java.lang.Throwable
Remove all the references in the channel

Throws:
java.lang.Throwable


Copyright © 2006 JBoss Inc. All Rights Reserved.