xmlBlaster 2.2.0 API

org.xmlBlaster.engine.distributor.plugins
Class ConsumableQueuePlugin

java.lang.Object
  extended by org.xmlBlaster.engine.distributor.plugins.ConsumableQueuePlugin
All Implemented Interfaces:
java.util.EventListener, I_MsgDistributor, I_SubscriptionListener, I_ConnectionStatusListener, I_Plugin

public class ConsumableQueuePlugin
extends java.lang.Object
implements I_MsgDistributor, I_ConnectionStatusListener

ConsumableQueuePlugin

Author:
Michele Laghi

Field Summary
private  Global global
           
(package private)  boolean isReady
           
(package private)  boolean isRunning
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  java.lang.Object mutex
           
private  PluginInfo pluginInfo
           
private  ServerScope serverScope
           
private  java.lang.String topicId
           
 
Fields inherited from interface org.xmlBlaster.engine.I_SubscriptionListener
PRIO_01, PRIO_05, PRIO_10
 
Constructor Summary
ConsumableQueuePlugin()
          The default constructor.
 
Method Summary
 void distribute(MsgUnitWrapper msgUnitWrapper)
          This method should not throw any exception so it is responsability of the plugin developer to catch Throwable and make the necessary error handling.
private  boolean distributeOneEntry(MsgUnitWrapper msgUnitWrapper, MsgQueueHistoryEntry entry, java.util.List subInfoList)
          Distributes one single entry taken from the history queue.
private  UpdateReturnQosServer doDistribute(SubscriptionInfo sub, MsgQueueUpdateEntry entry)
          Enforced by the I_DistributionInterceptor interface.
private  I_DispatchManager getDispatchManager(SubscriptionInfo subscriptionInfo)
           
 java.lang.Integer getPriority()
          The priority by which it will be invoked.
 java.lang.String getType()
           
 java.lang.String getVersion()
           
private  void givingUpDistribution(SubscriptionInfo sub, MsgUnitWrapper msgUnitWrapper, MsgQueueEntry entry, java.lang.Throwable e)
           
 void init(Global global, PluginInfo pluginInfo)
          Initializes the plugin
(package private)  void processHistoryQueue()
          Takes entries from the history queue and distributes it to the dispatcher framework until there are entries available or until the dispatcher framework is alive.
 void shutdown()
          It removes all subscriptions done on this topic
 void subscriptionAdd(SubscriptionEvent e)
          Invoked when a subscriber is added to the TopicHandler
 void subscriptionRemove(SubscriptionEvent e)
          Invoked when a subscriber is removed from the TopicHandler
 void toAlive(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
          Event arriving from one DispatchManager telling this plugin it can start distribute again.
 void toAliveSync(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
           
 void toDead(I_DispatchManager dispatchManager, ConnectionStateEnum oldState, XmlBlasterException xmlBlasterException)
           
 void toPolling(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
           
private  void toRunning()
          Invoked on status changes when it shall start to distribute entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

isReady

boolean isReady

isRunning

boolean isRunning

global

private Global global

log

private static java.util.logging.Logger log

pluginInfo

private PluginInfo pluginInfo

serverScope

private ServerScope serverScope

topicId

private java.lang.String topicId

mutex

private java.lang.Object mutex
Constructor Detail

ConsumableQueuePlugin

public ConsumableQueuePlugin()
The default constructor. Currently does nothing.

Method Detail

toRunning

private void toRunning()
Invoked on status changes when it shall start to distribute entries. This can either happen on publish, on subscribe or when a dispatcher becomes alive again. This method is synchronized to avoid more threads running concurrently (see processHistoryQueue).


distribute

public void distribute(MsgUnitWrapper msgUnitWrapper)
Description copied from interface: I_MsgDistributor
This method should not throw any exception so it is responsability of the plugin developer to catch Throwable and make the necessary error handling.

Specified by:
distribute in interface I_MsgDistributor
Parameters:
msgUnitWrapper - the entry to distribute
See Also:
Invoked by the TopicHandler on publish or subscribe. Starts the distributor thread and returnes immeditately. From here distribution is handled by another thread.

init

public void init(Global global,
                 PluginInfo pluginInfo)
          throws XmlBlasterException
Initializes the plugin

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException

getType

public java.lang.String getType()
Specified by:
getType in interface I_Plugin

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface I_Plugin

shutdown

public void shutdown()
              throws XmlBlasterException
It removes all subscriptions done on this topic

Specified by:
shutdown in interface I_Plugin
Throws:
XmlBlasterException - if an exception occurs. The exception is handled by the RunLevelManager depending on how the plugin has been configured with the action:

<action do='STOP' onShutdownRunlevel='2' sequence='5' onFail='resource.configuration.pluginFailed'> If onFail is defined to something, the RunLevelManager will stop.


getDispatchManager

private final I_DispatchManager getDispatchManager(SubscriptionInfo subscriptionInfo)

subscriptionAdd

public void subscriptionAdd(SubscriptionEvent e)
                     throws XmlBlasterException
Invoked when a subscriber is added to the TopicHandler

Specified by:
subscriptionAdd in interface I_SubscriptionListener
Parameters:
subscriptionInfo -
Throws:
XmlBlasterException

subscriptionRemove

public void subscriptionRemove(SubscriptionEvent e)
                        throws XmlBlasterException
Invoked when a subscriber is removed from the TopicHandler

Specified by:
subscriptionRemove in interface I_SubscriptionListener
Parameters:
subscriptionInfo -
Throws:
XmlBlasterException

toAlive

public void toAlive(I_DispatchManager dispatchManager,
                    ConnectionStateEnum oldState)
Event arriving from one DispatchManager telling this plugin it can start distribute again.

Specified by:
toAlive in interface I_ConnectionStatusListener

toPolling

public void toPolling(I_DispatchManager dispatchManager,
                      ConnectionStateEnum oldState)
Specified by:
toPolling in interface I_ConnectionStatusListener

toDead

public void toDead(I_DispatchManager dispatchManager,
                   ConnectionStateEnum oldState,
                   XmlBlasterException xmlBlasterException)
Specified by:
toDead in interface I_ConnectionStatusListener
xmlBlasterException - Can be null

toAliveSync

public void toAliveSync(I_DispatchManager dispatchManager,
                        ConnectionStateEnum oldState)
Specified by:
toAliveSync in interface I_ConnectionStatusListener

processHistoryQueue

void processHistoryQueue()
Takes entries from the history queue and distributes it to the dispatcher framework until there are entries available or until the dispatcher framework is alive.


distributeOneEntry

private boolean distributeOneEntry(MsgUnitWrapper msgUnitWrapper,
                                   MsgQueueHistoryEntry entry,
                                   java.util.List subInfoList)
Distributes one single entry taken from the history queue. This method is strict, it does not throw any exceptions. If one exception occurs inside this method, the distribution is interrupted, a dead letter is generated and the entry is removed from the history queue.

Parameters:
subInfoList - contains the SubscriptionInfo objects to scan. Once the message is processed by one of the dispatchers, the associated SessionInfo is put at the end of the list to allow some simple load balancing mechanism.
Returns:
true if the entry has been removed from the history queue. This happens if the entry could be sent successfully, or if distribution was given up due to an exception. It returns false if none of the subscribers were able to receive the message (to tell the invoker not to continue with distribution until the next event.

givingUpDistribution

private void givingUpDistribution(SubscriptionInfo sub,
                                  MsgUnitWrapper msgUnitWrapper,
                                  MsgQueueEntry entry,
                                  java.lang.Throwable e)

doDistribute

private UpdateReturnQosServer doDistribute(SubscriptionInfo sub,
                                           MsgQueueUpdateEntry entry)
                                    throws XmlBlasterException
Enforced by the I_DistributionInterceptor interface. It sends sychronously to the DispatchWorker this entry.

Throws:
XmlBlasterException

getPriority

public java.lang.Integer getPriority()
Description copied from interface: I_SubscriptionListener
The priority by which it will be invoked. Lower numbers are invoked first on subscribe and last on unsubscribe.

Specified by:
getPriority in interface I_SubscriptionListener
Returns:
See Also:
I_SubscriptionListener.getPriority()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.