org.ikasan.framework.initiator.messagedriven
Class JmsMessageDrivenInitiatorImpl

java.lang.Object
  extended by org.ikasan.framework.initiator.AbstractInitiator
      extended by org.ikasan.framework.initiator.messagedriven.JmsMessageDrivenInitiatorImpl
All Implemented Interfaces:
javax.jms.MessageListener, Initiator, JmsMessageDrivenInitiator, ListenerSetupFailureListener, MonitorSubject
Direct Known Subclasses:
EventMessageDrivenInitiator, RawMessageDrivenInitiator

public abstract class JmsMessageDrivenInitiatorImpl
extends AbstractInitiator
implements JmsMessageDrivenInitiator, MonitorSubject, ListenerSetupFailureListener

Abstract base class for JMS Message Driven Initiators Subclasses will provide an implementation for handling of one or more of the specific JMS Message types into an Event

Author:
Ikasan Development Team

Field Summary
protected  org.ikasan.framework.initiator.messagedriven.JmsMessageDrivenInitiatorImpl.Anesthetist anesthetist
          The Anesthetist for stopping/starting the message listener container
static String JMS_MESSAGE_DRIVEN_INITIATOR_TYPE
           
protected  MessageListenerContainer messageListenerContainer
          The message listener container
 
Fields inherited from class org.ikasan.framework.initiator.AbstractInitiator
error, errorLoggingService, EXCEPTION_ACTION_IMPLIED_ROLLBACK, exceptionHandler, excludedEventService, exclusions, flow, moduleName, monitorListeners, name, retryCount, stopping, UNSUPPORTED_EXCLUDE_ENCONTERED
 
Constructor Summary
JmsMessageDrivenInitiatorImpl(String moduleName, String name, Flow flow, IkasanExceptionHandler exceptionHandler)
          Constructor
 
Method Summary
protected  boolean anesthetistOperating()
          Return true if the anesthetist is operating
protected  void cancelRetryCycle()
          Cancels retry activity
protected  void completeRetryCycle()
          Cancel the retry activity, and resume any business as usual activity
protected  void continueRetryCycle(long delay)
          Template method for subclasses to selectively override
 MessageListenerContainer getMessageListenerContainer()
          Accessor for messageListenerContainer
 String getType()
          Returns the type of the initiator
protected  Event handleBytesMessage(javax.jms.BytesMessage message)
          JMS Message specific type handling for BytesMessage Subclasses that wish to support this Message type will override this
protected  Event handleMapMessage(javax.jms.MapMessage message)
          JMS Message specific type handling for MapMessage Subclasses that wish to support this Message type will override this
protected  Event handleObjectMessage(javax.jms.ObjectMessage message)
          JMS Message specific type handling for ObjectMessage Subclasses that wish to support this Message type will override this
protected  Event handleStreamMessage(javax.jms.StreamMessage message)
          JMS Message specific type handling for StreamMessage Subclasses that wish to support this Message type will override this
protected  Event handleTextMessage(javax.jms.TextMessage message)
          JMS Message specific type handling for TextMessage Subclasses that wish to support this Message type will override this
 boolean isRecovering()
          Is this initiator in a recovering state.
 boolean isRunning()
          Is this initiator running.
 void notifyListenerSetupFailure(Throwable throwable)
          Notify error during listener setup
 void onMessage(javax.jms.Message message)
           
 void setListenerSetupFailureRetryDelay(int listenerSetupFailureRetryDelay)
          Setter for overriding the default value (10000)of listenerSetupFailureRetryDelay
 void setMaxListenerSetupFailureRetries(int maxListenerSetupFailureRetries)
          Setter for overriding the default value (Indefinite) of listenerSetupFailureRetryDelay
 void setMessageListenerContainer(MessageListenerContainer messageListenerContainer)
           
protected  void startInitiator()
          Only the extending class knows how to start the initiator.
protected  void startRetryCycle(Integer maxAttempts, long delay)
          Initiator needs to start a retry cycle due to an exception action.
protected  void stopInitiator()
          Only the extending class knows how to stop the initiator.
 
Methods inherited from class org.ikasan.framework.initiator.AbstractInitiator
addListener, getExceptionHandler, getExclusions, getFlow, getHandledEventCount, getLastEventTime, getLogger, getModuleName, getMonitorListeners, getName, getRetryCount, getState, handleAction, handleRetry, invokeFlow, invokeFlow, isError, isStopping, logError, notifyMonitorListeners, removeListener, resume, setErrorLoggingService, setExcludedEventService, start, stop, stopInError, supportsExclusions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ikasan.framework.initiator.Initiator
getExceptionHandler, getFlow, getHandledEventCount, getLastEventTime, getName, getRetryCount, getState, isError, start, stop
 
Methods inherited from interface org.ikasan.framework.monitor.MonitorSubject
addListener, removeListener
 

Field Detail

JMS_MESSAGE_DRIVEN_INITIATOR_TYPE

public static final String JMS_MESSAGE_DRIVEN_INITIATOR_TYPE
See Also:
Constant Field Values

messageListenerContainer

protected MessageListenerContainer messageListenerContainer
The message listener container


anesthetist

protected org.ikasan.framework.initiator.messagedriven.JmsMessageDrivenInitiatorImpl.Anesthetist anesthetist
The Anesthetist for stopping/starting the message listener container

Constructor Detail

JmsMessageDrivenInitiatorImpl

public JmsMessageDrivenInitiatorImpl(String moduleName,
                                     String name,
                                     Flow flow,
                                     IkasanExceptionHandler exceptionHandler)
Constructor

Parameters:
moduleName - The name of the module
name - The name of this initiator
flow - The name of the flow it starts
exceptionHandler - handler for Exceptions
Method Detail

getType

public String getType()
Description copied from interface: Initiator
Returns the type of the initiator

Specified by:
getType in interface Initiator
Returns:
type

onMessage

public void onMessage(javax.jms.Message message)
Specified by:
onMessage in interface javax.jms.MessageListener

completeRetryCycle

protected void completeRetryCycle()
Description copied from class: AbstractInitiator
Cancel the retry activity, and resume any business as usual activity

Specified by:
completeRetryCycle in class AbstractInitiator

startRetryCycle

protected void startRetryCycle(Integer maxAttempts,
                               long delay)
Description copied from class: AbstractInitiator
Initiator needs to start a retry cycle due to an exception action. Only the extending class has the knowledge to start a retry cycle.

Specified by:
startRetryCycle in class AbstractInitiator
delay - The delay in milliseconds before we perform a retry

continueRetryCycle

protected void continueRetryCycle(long delay)
Description copied from class: AbstractInitiator
Template method for subclasses to selectively override

Overrides:
continueRetryCycle in class AbstractInitiator

cancelRetryCycle

protected void cancelRetryCycle()
Description copied from class: AbstractInitiator
Cancels retry activity

Specified by:
cancelRetryCycle in class AbstractInitiator

isRecovering

public boolean isRecovering()
Description copied from interface: Initiator
Is this initiator in a recovering state. This recovering state also denotes this initiator as running.

Specified by:
isRecovering in interface Initiator
Returns:
boolean

isRunning

public boolean isRunning()
Description copied from interface: Initiator
Is this initiator running.

Specified by:
isRunning in interface Initiator
Returns:
boolean

anesthetistOperating

protected boolean anesthetistOperating()
Return true if the anesthetist is operating

Returns:
true if the anesthetist is operating

startInitiator

protected void startInitiator()
Description copied from class: AbstractInitiator
Only the extending class knows how to start the initiator.

Specified by:
startInitiator in class AbstractInitiator

stopInitiator

protected void stopInitiator()
Description copied from class: AbstractInitiator
Only the extending class knows how to stop the initiator.

Specified by:
stopInitiator in class AbstractInitiator

setMessageListenerContainer

public void setMessageListenerContainer(MessageListenerContainer messageListenerContainer)
Parameters:
messageListenerContainer - the messageListenerContainer to set

getMessageListenerContainer

public MessageListenerContainer getMessageListenerContainer()
Accessor for messageListenerContainer

Specified by:
getMessageListenerContainer in interface JmsMessageDrivenInitiator
Returns:

notifyListenerSetupFailure

public void notifyListenerSetupFailure(Throwable throwable)
Description copied from interface: ListenerSetupFailureListener
Notify error during listener setup

Specified by:
notifyListenerSetupFailure in interface ListenerSetupFailureListener

handleBytesMessage

protected Event handleBytesMessage(javax.jms.BytesMessage message)
                            throws javax.jms.JMSException
JMS Message specific type handling for BytesMessage Subclasses that wish to support this Message type will override this

Parameters:
message - The message to handle
Returns:
Event The event containing the message
Throws:
javax.jms.JMSException - Exception if there is a problem with JMS

handleStreamMessage

protected Event handleStreamMessage(javax.jms.StreamMessage message)
                             throws javax.jms.JMSException,
                                    EventDeserialisationException
JMS Message specific type handling for StreamMessage Subclasses that wish to support this Message type will override this

Parameters:
message - The message to handle
Returns:
Event
Throws:
javax.jms.JMSException
EventDeserialisationException

handleObjectMessage

protected Event handleObjectMessage(javax.jms.ObjectMessage message)
                             throws javax.jms.JMSException,
                                    EventDeserialisationException
JMS Message specific type handling for ObjectMessage Subclasses that wish to support this Message type will override this

Parameters:
message - The message to handle
Returns:
Event
Throws:
javax.jms.JMSException - Exception if there is a problem with JMS
EventDeserialisationException

handleMapMessage

protected Event handleMapMessage(javax.jms.MapMessage message)
                          throws javax.jms.JMSException,
                                 EventDeserialisationException
JMS Message specific type handling for MapMessage Subclasses that wish to support this Message type will override this

Parameters:
message - The message to handle
Returns:
Event
Throws:
javax.jms.JMSException - Exception if there is a problem with JMS
EventDeserialisationException

handleTextMessage

protected Event handleTextMessage(javax.jms.TextMessage message)
                           throws javax.jms.JMSException,
                                  EventDeserialisationException
JMS Message specific type handling for TextMessage Subclasses that wish to support this Message type will override this

Parameters:
message - The message to handle
Returns:
Event
Throws:
javax.jms.JMSException - Exception if there is a problem with JMS
EventDeserialisationException

setListenerSetupFailureRetryDelay

public void setListenerSetupFailureRetryDelay(int listenerSetupFailureRetryDelay)
Setter for overriding the default value (10000)of listenerSetupFailureRetryDelay

Parameters:
listenerSetupFailureRetryDelay - in milliseconds

setMaxListenerSetupFailureRetries

public void setMaxListenerSetupFailureRetries(int maxListenerSetupFailureRetries)
Setter for overriding the default value (Indefinite) of listenerSetupFailureRetryDelay

Parameters:
maxListenerSetupFailureRetries -


Copyright © 2007-2012 Ikasan. All Rights Reserved.