org.mactor.brokers
Class AbstractMessageBroker

java.lang.Object
  extended by org.mactor.brokers.AbstractMessageBroker
All Implemented Interfaces:
MessageBroker
Direct Known Subclasses:
HttpMessageBroker, JmsMessageBroker, PollingMessageBrokerTemplate, SoapMessageBroker, TibcoRvMessageBroker

public abstract class AbstractMessageBroker
extends java.lang.Object
implements MessageBroker

Abstract class that contains functinally common to most message broker implementations (such as maintaining subscribers).

Author:
Lars Ivar Almli

Field Summary
protected  MessageBrokersConfig.MessageBrokerConfig config
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
AbstractMessageBroker(MessageBrokersConfig.MessageBrokerConfig config)
           
 
Method Summary
protected abstract  void onFirstSubscribe(java.lang.String channel)
           
protected abstract  void onLastSubscribe(java.lang.String channel)
           
protected  Message raiseOnMessage(java.lang.String channel, Message message, boolean broadcast)
          This method shold be invoked message broker implementations when message is received.
 void subscribe(java.lang.String channel, MessageSubscriber subscriber, MessageSelectorCommand messageSelector)
          Subscibe to message from a channel
 void terminate()
           
 void unsubscribe(java.lang.String channel, MessageSubscriber subscriber)
          Unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mactor.brokers.MessageBroker
publish, publishWithResponse
 

Field Detail

log

protected static org.apache.log4j.Logger log

config

protected MessageBrokersConfig.MessageBrokerConfig config
Constructor Detail

AbstractMessageBroker

public AbstractMessageBroker(MessageBrokersConfig.MessageBrokerConfig config)
Method Detail

terminate

public void terminate()
Specified by:
terminate in interface MessageBroker

subscribe

public void subscribe(java.lang.String channel,
                      MessageSubscriber subscriber,
                      MessageSelectorCommand messageSelector)
               throws MactorException
Description copied from interface: MessageBroker
Subscibe to message from a channel

Specified by:
subscribe in interface MessageBroker
Parameters:
channel - the channel
subscriber - the subscriber that will receive the messages
messageSelector - the message selector restricts which messages to receive from the channel
Throws:
MactorException - if some problem occures (this will cause the test to fail)

unsubscribe

public void unsubscribe(java.lang.String channel,
                        MessageSubscriber subscriber)
                 throws MactorException
Description copied from interface: MessageBroker
Unsubscribe

Specified by:
unsubscribe in interface MessageBroker
Parameters:
channel - the channel
subscriber - the subscriber
Throws:
MactorException - if some problem occures

raiseOnMessage

protected Message raiseOnMessage(java.lang.String channel,
                                 Message message,
                                 boolean broadcast)
                          throws MactorException
This method shold be invoked message broker implementations when message is received. The method delivers the message to the subscribers of the channel

Parameters:
channel - the channel the message was recevied
message - the message
broadcast - a flag that indicates if the message should be distributed to all subscribers that accepts the message, or just the first (random) subscriber that accepets the message.
Returns:
a result message that might be used by message broker implementation to return a synchrounous result to the source of the incoming messages.
Throws:
MactorException

onFirstSubscribe

protected abstract void onFirstSubscribe(java.lang.String channel)
                                  throws MactorException
Throws:
MactorException

onLastSubscribe

protected abstract void onLastSubscribe(java.lang.String channel)
                                 throws MactorException
Throws:
MactorException


Copyright © 2008. All Rights Reserved.