atg.commerce.messaging
Class SourceSinkTemplate

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.messaging.SourceSinkTemplate
All Implemented Interfaces:
MessageSink, MessageSource, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
FulfillerSystem, LocalizingInventoryManager, MessageForwardFilter, MessagePipelineMapper, MessageSender, OrderCanceller, OrderCanceller, OrderChangeHandler, PricingTools, RepositoryInventoryManager

public class SourceSinkTemplate
extends GenericService
implements MessageSource, MessageSink

This class handles the sending and receiving of CommerceMessage. All classes in fulfillment that send and receive messages will extend this class. Classes that extend this will appear in the configuration XML file for patchbay.

See Also:
CommerceMessage

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
SourceSinkTemplate()
           
 
Method Summary
 int getDelayOnSendRetry()
          The number of milliseconds to wait when trying to send a message before the DMS system tells us it is ok.
 MessageSourceContext getMessageSourceContext()
          Return the message source context for this source.
 java.lang.String getMessageSourceName()
          This defines the string that the source property of messages will be set to.
 javax.transaction.TransactionManager getTransactionManager()
          The beginning and ending of transactions are handled by the transaction manager.
 boolean isAllowMessageSending()
          This class cannot send messages if this is false.
 void receiveMessage(java.lang.String pPortName, javax.jms.Message pMessage)
           This is called to notify the component that a Message has arrived through the given input port.
 void sendCommerceMessage(CommerceMessage pCommerceMessage, java.lang.String pPortName)
          This is a convenience method which wraps the CommerceMessage to be sent into an ObjectMessage and sends it along the port that is specified.
 void sendObjectMessage(java.io.Serializable pObjectMessage, java.lang.String pType, java.lang.String pPortName)
          Sends an object message of type pType, out on port pPortName.
 void setAllowMessageSending(boolean pAllowMessageSending)
           
 void setDelayOnSendRetry(int pDelayOnSendRetry)
           
 void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
          Set the message source context for this source.
 void setMessageSourceName(java.lang.String pMessageSourceName)
           
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
           
 void startMessageSource()
          This is called to tell the MessageSource that it may begin sending messages.
 void stopMessageSource()
          This is called to tell the MessageSource that it should stop sending messages.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

SourceSinkTemplate

public SourceSinkTemplate()
Method Detail

setMessageSourceContext

public void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
Set the message source context for this source.

Specified by:
setMessageSourceContext in interface MessageSource
See Also:
MessageSource

getMessageSourceContext

public MessageSourceContext getMessageSourceContext()
Return the message source context for this source.


setMessageSourceName

public void setMessageSourceName(java.lang.String pMessageSourceName)

getMessageSourceName

public java.lang.String getMessageSourceName()
This defines the string that the source property of messages will be set to.


setAllowMessageSending

public void setAllowMessageSending(boolean pAllowMessageSending)

isAllowMessageSending

public boolean isAllowMessageSending()
This class cannot send messages if this is false. Usually set during parsing of the configuration file.


setDelayOnSendRetry

public void setDelayOnSendRetry(int pDelayOnSendRetry)

getDelayOnSendRetry

public int getDelayOnSendRetry()
The number of milliseconds to wait when trying to send a message before the DMS system tells us it is ok. This is necessary if we receive a message before we are allowed to send a message. If we are still unable to send after this delay, then we will rollback the current transaction. The default value is 30000 (30 seconds)


startMessageSource

public void startMessageSource()
This is called to tell the MessageSource that it may begin sending messages.

Specified by:
startMessageSource in interface MessageSource

stopMessageSource

public void stopMessageSource()
This is called to tell the MessageSource that it should stop sending messages.

Specified by:
stopMessageSource in interface MessageSource

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
The beginning and ending of transactions are handled by the transaction manager.


receiveMessage

public void receiveMessage(java.lang.String pPortName,
                           javax.jms.Message pMessage)
                    throws javax.jms.JMSException

This is called to notify the component that a Message has arrived through the given input port. The MessageSink should be prepared to handle concurrent calls of this method from multiple Threads. This is left as an empty method in this class and should be overriden by the implementor.

receiveMessage can be extended to handle extra types of messages by overriding the handleNewMessageType method.

Specified by:
receiveMessage in interface MessageSink
Throws:
javax.jms.JMSException

sendCommerceMessage

public void sendCommerceMessage(CommerceMessage pCommerceMessage,
                                java.lang.String pPortName)
                         throws javax.jms.JMSException
This is a convenience method which wraps the CommerceMessage to be sent into an ObjectMessage and sends it along the port that is specified.

Parameters:
pCommerceMessage - The message to be sent.
pPortName - The port to send the message to.
Throws:
javax.jms.JMSException

sendObjectMessage

public void sendObjectMessage(java.io.Serializable pObjectMessage,
                              java.lang.String pType,
                              java.lang.String pPortName)
                       throws javax.jms.JMSException
Sends an object message of type pType, out on port pPortName.

Parameters:
pObjectMessage - the object to be placed in the object message.
pType - the type of the message being sent.
pPortName - the port on which this message is going to be sent.
Throws:
javax.jms.JMSException - is thrown when a failure to send the message occurs. This is generally a configuration issue.