Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.messaging.core
Class ChannelSupport

    java.lang.Object
      org.jboss.messaging.core.ChannelSupport

All Implemented Interfaces:
  Channel, DeliveryObserver, Distributor, Receiver

Direct Known Subclasses:
  Pipe, Queue

public abstract class ChannelSupport
extends java.lang.Object
implements Channel

A basic channel implementation. It supports atomicity, isolation and, if a non-null PersistenceManager is available, it supports recoverability of reliable messages.

Version:
  `$Revision: 1.65 $` $Id: ChannelSupport.java,v 1.65 2006/06/27 19:44:39 timfox Exp $
Author:
  Ovidiu Feodorov, Tim Fox

Field Summary
`protected long` | `channelID`
`protected MemoryManager` | `mm`
`protected MessageStore` | `ms`
`protected PersistenceManager` | `pm`
`protected Router` | `router`
`protected State` | `state`

Constructor Summary
`protected` | `ChannelSupport(long channelID, MessageStore ms, PersistenceManager pm, MemoryManager mm, boolean acceptReliableMessages, boolean recoverable, int fullSize, int pageSize, int downCacheSize)`

Method Summary
`boolean` | `acceptReliableMessages()` A non-recoverable channel cannot guarantee recoverability for reliable messages so by default it won't accept reliable messages.
`void` | `acknowledge(Delivery d, Transaction tx)`
`boolean` | `add(Receiver r)` Add a local receiver to this distributor.
`java.util.List` | `browse()`
`java.util.List` | `browse(Filter f)`
`void` | `cancel(Delivery d)`
`void` | `clear()` Remove all receivers.
`void` | `close()`
`boolean` | `contains(Receiver r)`
`boolean` | `deliver()`
`protected boolean` | `deliver(DeliveryObserver sender, Receiver receiver)` Delivery for the channel must be synchronized.
`boolean` | `deliver(Receiver r)` Synchronously pushes the "oldest" message stored by the channel to the receiver.
`long` | `getChannelID()`
`MessageStore` | `getMessageStore()`
`Delivery` | `handle(DeliveryObserver sender, Routable r, Transaction tx)` A receiver can return an active, "done" or null delivery.
`boolean` | `isRecoverable()`
`java.util.Iterator` | `iterator()`
`protected MessageReference` | `obtainReference(Routable r)`
`protected void` | `processMessageBeforeStorage(MessageReference reference)` Give subclass a chance to process the message before storing it internally.
`boolean` | `remove(Receiver r)` Remove a local receiver from this distributor.
`void` | `removeAllMessages()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### channelID

    protected long channelID

### router

    protected Router router

### state

    protected State state

### ms

    protected MessageStore ms

### pm

    protected PersistenceManager pm

### mm

    protected MemoryManager mm

Constructor Detail

### ChannelSupport

    protected ChannelSupport(long channelID,
                             MessageStore ms,
                             PersistenceManager pm,
                             MemoryManager mm,
                             boolean acceptReliableMessages,
                             boolean recoverable,
                             int fullSize,
                             int pageSize,
                             int downCacheSize)

Parameters:
  `acceptReliableMessages` - - it only makes sense if tl is null. Otherwise ignored (a recoverable channel always accepts reliable messages)

Method Detail

### handle

    public Delivery handle(DeliveryObserver sender,
                           Routable r,
                           Transaction tx)

  Description copied from interface: `Receiver`
  A receiver can return an active, "done" or null delivery. The method returns null in case the receiver doesn't accept the message. The return value is unspecified when the message is submitted in the context of a transaction (tx not null).

  Specified by:
    `handle` in interface `Receiver`
  Parameters:
    `sender` - - the component the delivery should be acknowledged to.
  See Also:
    `Delivery`, `DeliveryObserver`

### acknowledge

    public void acknowledge(Delivery d,
                            Transaction tx)

  Specified by:
    `acknowledge` in interface `DeliveryObserver`

### cancel

    public void cancel(Delivery d)
                throws java.lang.Throwable

  Specified by:
    `cancel` in interface `DeliveryObserver`
  Throws:
    `java.lang.Throwable`

### add

    public boolean add(Receiver r)

  Description copied from interface: `Distributor`
  Add a local receiver to this distributor.

  Specified by:
    `add` in interface `Distributor`
  Returns:
    true if the distributor did not already contain the specified receiver and the receiver was added to the distributor, false otherwise.

### remove

    public boolean remove(Receiver r)

  Description copied from interface: `Distributor`
  Remove a local receiver from this distributor.

  Specified by:
    `remove` in interface `Distributor`
  Returns:
    true if this distributor contained the specified receiver.

### clear

    public void clear()

  Description copied from interface: `Distributor`
  Remove all receivers.

  Specified by:
    `clear` in interface `Distributor`

### contains

    public boolean contains(Receiver r)

  Specified by:
    `contains` in interface `Distributor`

### iterator

    public java.util.Iterator iterator()

  Specified by:
    `iterator` in interface `Distributor`
  Returns:
    an iterator of local receivers

### getChannelID

    public long getChannelID()

  Specified by:
    `getChannelID` in interface `Channel`

### isRecoverable

    public boolean isRecoverable()

  Specified by:
    `isRecoverable` in interface `Channel`
  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()

  Description copied from interface: `Channel`
  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.

  Specified by:
    `acceptReliableMessages` in interface `Channel`
  Returns:
    false if the channel doesn't accept reliable messages.
  See Also:
    `State.acceptReliableMessages()`

### browse

    public java.util.List browse()

  Specified by:
    `browse` in interface `Channel`
  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 f)

  Specified by:
    `browse` in interface `Channel`
  See Also:
    `Channel.browse()`

### getMessageStore

    public MessageStore getMessageStore()

  Specified by:
    `getMessageStore` in interface `Channel`

### deliver

    public boolean deliver()

  Specified by:
    `deliver` in interface `Channel`

### deliver

    public boolean deliver(Receiver r)

  Description copied from interface: `Channel`
  Synchronously pushes the "oldest" message stored by the channel to the receiver. If receiver is null, it delivers the message to the first available receiver.

  Specified by:
    `deliver` in interface `Channel`
  Returns:
    true if a message was handed over to the receiver and the channel got a delivery in exchange, or false otherwise.

### close

    public void close()

  Specified by:
    `close` in interface `Channel`

### removeAllMessages

    public void removeAllMessages()

### obtainReference

    protected MessageReference obtainReference(Routable r)

### processMessageBeforeStorage

    protected void processMessageBeforeStorage(MessageReference reference)

  Give subclass a chance to process the message before storing it internally. Useful to get rid of the REMOTE_ROUTABLE header in a distributed case, for example.

### deliver

    protected boolean deliver(DeliveryObserver sender,
                              Receiver receiver)
                       throws java.lang.Throwable

  Delivery for the channel must be synchronized. Otherwise we can end up with the same message being delivered more than once to the same consumer (if deliver() is called concurrently) or messages being delivered in the wrong order.

  Throws:
    `java.lang.Throwable`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 JBoss Inc. All Rights Reserved.