org.jph.channels.router
Interface RoutingOutputChannel<M>

All Superinterfaces:
OutputChannel<M>
All Known Implementing Classes:
StdRoutingOutputChannel

public interface RoutingOutputChannel<M>
extends OutputChannel<M>

The RoutingOutputChannel is an OutputChannel that receives messages and publishes them to one or more subscribing outputchannels.

Every subscribing outputchannel is registered with a MessagePredicate that checks if the subscriber wants the message .

If there are multiple subscribers for a message, the timeout will decrease after every offer. So if the original timeout was 1000ms, and the first took 300ms, 700 ms remains for the second. If the second took 500ms, 200ms remains for the third. If the third takes 300ms, a timeout will occur (what happens next?) if the third takes 200ms, 0ms remains for the other ones. So if the timeout is reduced to 0ms, all the next subscribers will be called with 0ms.

Author:
Peter Veentjer.

Method Summary
 void add(OutRouterEntry<M> entry)
           
 java.util.Iterator<OutRouterEntry<M>> entries()
          Returns all the OutRouterEntries.
 OutputChannel<M> getFailOutputChannel()
          Returns the OutputChannel that is used if a message could not be send to a receiver.
 boolean isStopAfterFirst()
          Returns true if this RoutingOutputChannel should stop sending messages to other receivers if one receiver succesfully has received a message.
 void subscribe(OutputChannel<M> subscriber)
          Adds the subscriber to this RoutingOutputChannel.
 void subscribe(org.jph.collections.predicate.Predicate predicate, OutputChannel<M> subscriber)
          Adds a subscriber to this RoutingOutputChannel.
 
Methods inherited from interface org.jph.channels.OutputChannel
offer, put
 

Method Detail

isStopAfterFirst

boolean isStopAfterFirst()
Returns true if this RoutingOutputChannel should stop sending messages to other receivers if one receiver succesfully has received a message.


getFailOutputChannel

OutputChannel<M> getFailOutputChannel()
Returns the OutputChannel that is used if a message could not be send to a receiver.


entries

java.util.Iterator<OutRouterEntry<M>> entries()
Returns all the OutRouterEntries.


add

void add(OutRouterEntry<M> entry)
Parameters:
entry -
Throws:
java.lang.NullPointerException - if entry is null.

subscribe

void subscribe(OutputChannel<M> subscriber)
Adds the subscriber to this RoutingOutputChannel. The subscriber will receive all messages this RoutingOutputChannel receives.

Parameters:
subscriber - the subscriber to add. If the subscriber already is a subscriber for this RoutingOutputChannel, it is not added again.
Throws:
java.lang.NullPointerException - if subscriber is null.

subscribe

void subscribe(org.jph.collections.predicate.Predicate predicate,
               OutputChannel<M> subscriber)
Adds a subscriber to this RoutingOutputChannel. The subscriber only receives messages that where checked by a MessagePredicate. This way you can listen to certain messages.

Parameters:
predicate - if the predicate is null, the TrueMessagePredicate is used by default.
subscriber -
Throws:
java.lang.NullPointerException - subscriber is null.


Copyright © 2005 Anchormen. All Rights Reserved.