org.jboss.messaging.core.plugin.postoffice.cluster
Class DefaultRouter

java.lang.Object
  extended byorg.jboss.messaging.core.plugin.postoffice.cluster.DefaultRouter
All Implemented Interfaces:
ClusterRouter, Distributor, Receiver, Router

public class DefaultRouter
extends java.lang.Object
implements ClusterRouter

This router favours the local queue. If there is no local queue, then it will round robin between the non local queues.

Version:
$Revision: 2735 $ $Id: DefaultRouter.java 2735 2007-05-29 16:01:31Z timfox $
Author:
Tim Fox, Ovidiu Feodorov

Constructor Summary
DefaultRouter()
           
 
Method Summary
 boolean add(Receiver receiver)
          Add a local receiver to this distributor.
 boolean add(Receiver receiver, boolean failedOver)
           
 void clear()
          Remove all receivers.
 boolean contains(Receiver queue)
           
 Queue getLocalQueue()
           
 int getNumberOfReceivers()
           
 java.util.List getQueues()
           
 Delivery handle(DeliveryObserver observer, MessageReference ref, Transaction tx)
          A receiver can return an active, "done" or null delivery.
 java.util.Iterator iterator()
           
 boolean remove(Receiver queue)
          Remove a local receiver from this distributor.
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultRouter

public DefaultRouter()
Method Detail

handle

public Delivery handle(DeliveryObserver observer,
                       MessageReference ref,
                       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:
observer - - the component the delivery should be acknowledged to.
See Also:
Delivery, DeliveryObserver

contains

public boolean contains(Receiver queue)
Specified by:
contains in interface Distributor

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface Distributor
Returns:
an iterator of local receivers

add

public boolean add(Receiver receiver)
Description copied from interface: Distributor
Add a local receiver to this distributor.

Specified by:
add in interface ClusterRouter

remove

public boolean remove(Receiver queue)
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

getNumberOfReceivers

public int getNumberOfReceivers()
Specified by:
getNumberOfReceivers in interface Distributor
Returns:
The number of receivers in the distributor

getQueues

public java.util.List getQueues()
Specified by:
getQueues in interface ClusterRouter

getLocalQueue

public Queue getLocalQueue()
Specified by:
getLocalQueue in interface ClusterRouter

add

public boolean add(Receiver receiver,
                   boolean failedOver)

size

public int size()

toString

public java.lang.String toString()


Copyright © 2006 JBoss Inc. All Rights Reserved.