Class Adapter

All Implemented Interfaces:
IAdapter, IConfigurable, IConfigurationAware, IManagable, INamedObject, IScopeProvider, HasStatistics, org.springframework.beans.factory.Aware, org.springframework.beans.factory.NamedBean, org.springframework.context.ApplicationContextAware

@Category("Basic") public class Adapter extends Object implements IAdapter, org.springframework.beans.factory.NamedBean
An Adapter receives a specific type of messages and processes them. It has Receivers that receive the messages and a PipeLine that transforms the incoming messages. Each adapter is part of a Configuration.
If an adapter can receive its messages through multiple channels (e.g. RESTful HTTP requests, incoming files, etc), each channel appears as a separate Receiver nested in the adapter. Each Receiver is also responsible for dealing with the result of its received messages; the result is the output of the PipeLine. The result consists of the transformed message and a state. The Frank!Framework distinguishes between exit states SUCCESS and ERROR. There is also a state REJECTED for messages that are not accepted by the Frank!Framework and that are not processed by the PipeLine. If the exit state is ERROR, the result message may not be usable by the calling system. This can be fixed by adding an errorMessageFormatter that formats the result message if the state is ERROR.

Adapters gather statistics about the messages they process.
Adapters can process messages in parallel. They are thread-safe.
Johan Verrips
  • Field Details

  • Constructor Details

    • Adapter

      public Adapter()
  • Method Details

    • getAdapter

      public Adapter getAdapter()
      Specified by:
      getAdapter in interface HasStatistics
    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IAdapter
      Instruct the adapter to configure itself. The adapter will call the pipeline to configure itself, the pipeline will call the individual pipes to configure themselves.
      Specified by:
      configure in interface IAdapter
      Specified by:
      configure in interface IConfigurable
      See Also:
    • configureReceiver

      public void configureReceiver(Receiver<?> receiver) throws ConfigurationException
    • configurationSucceeded

      public boolean configurationSucceeded()
    • warn

      protected void warn(String msg)
      send a warning to the log and to the messagekeeper of the adapter
    • addErrorMessageToMessageKeeper

      protected void addErrorMessageToMessageKeeper(String msg, Throwable t)
      send an error to the log and to the messagekeeper of the adapter
    • setLastExitState

      public void setLastExitState(String pipeName, long lastExitStateDate, String lastExitState)
    • getLastExitIsTimeoutDate

      public long getLastExitIsTimeoutDate(String pipeName)
    • formatErrorMessage

      public Message formatErrorMessage(String errorMessage, Throwable t, Message originalMessage, String messageID, INamedObject objectInError, long receivedTime)
      Specified by:
      formatErrorMessage in interface IAdapter
    • getLastMessageDate

      @JmxAttribute(description="The date/time of the last processed message") public String getLastMessageDate()
      retrieve the date and time of the last message.
    • getLastMessageDateDate

      public Date getLastMessageDateDate()
    • getMessageKeeper

      public MessageKeeper getMessageKeeper()
      the MessageKeeper is for keeping the last messageKeeperSize messages available, for instance for displaying it in the webcontrol
      Specified by:
      getMessageKeeper in interface IAdapter
      See Also:
    • getNumOfMessagesInError

      @JmxAttribute(description="# Messages in Error") public double getNumOfMessagesInError()
      The number of messages for which processing ended unsuccessfully.
    • getNumOfMessagesInProcess

      @JmxAttribute(description="# Messages in process") public int getNumOfMessagesInProcess()
    • getNumOfMessagesStartProcessingByHour

      public long[] getNumOfMessagesStartProcessingByHour()
    • getNumOfMessagesProcessed

      @JmxAttribute(description="# Messages Processed") public double getNumOfMessagesProcessed()
      Total of messages processed
      long total messages processed
    • getReceiverByName

      public Receiver<?> getReceiverByName(String receiverName)
      Specified by:
      getReceiverByName in interface IAdapter
    • getReceivers

      public Iterable<Receiver<?>> getReceivers()
      Specified by:
      getReceivers in interface IAdapter
    • getRunState

      public RunState getRunState()
      Description copied from interface: IManagable
      returns the runstate of the object. Possible values are defined by RunState.
      Specified by:
      getRunState in interface IManagable
    • getRunStateAsString

      @JmxAttribute(description="RunState") public String getRunStateAsString()
    • getStatsUpSince

      @JmxAttribute(description="Up Since") public String getStatsUpSince()
      return the date and time since active Creation date: (19-02-2003 12:16:53)
      String Date
    • getStatsUpSinceDate

      public Date getStatsUpSinceDate()
    • logToMessageLogWithMessageContentsOrSize

      public void logToMessageLogWithMessageContentsOrSize(org.apache.logging.log4j.Level level, String logMessage, String dataPrefix, Message data)
    • processMessage

      public PipeLineResult processMessage(String messageId, Message message, PipeLineSession pipeLineSession)
      Specified by:
      processMessage in interface IAdapter
    • processMessageWithExceptions

      public PipeLineResult processMessageWithExceptions(String messageId, Message message, PipeLineSession pipeLineSession) throws ListenerException
      Specified by:
      processMessageWithExceptions in interface IAdapter
    • registerReceiver

      public void registerReceiver(Receiver<?> receiver)
      Receives incoming messages. If an adapter can receive messages through multiple channels, then add a receiver for each channel.
    • setErrorMessageFormatter

      public void setErrorMessageFormatter(IErrorMessageFormatter errorMessageFormatter)
      Formatter for errors that can occur in this adapter.
    • setPipeLine

      public void setPipeLine(PipeLine pipeline)
      Specified by:
      setPipeLine in interface IAdapter
    • getPipeLine

      public PipeLine getPipeLine()
      Specified by:
      getPipeLine in interface IAdapter
    • setConfiguration

      public void setConfiguration(Configuration configuration)
      Specified by:
      setConfiguration in interface IAdapter
    • startRunning

      public void startRunning()
      Start the adapter. The thread-name will be set to the adapter's name. The run method, called by t.start(), will call the startRunning method of the IReceiver. The Adapter will be a new thread, as this interface extends the Runnable interface. The actual starting is done in the run method.
      Specified by:
      startRunning in interface IManagable
      See Also:
    • stopRunning

      public void stopRunning()
      Stop the Adapter and close all elements like receivers, Pipeline, pipes etc. The adapter will call the IReceiver to stopListening

      Also the PipeLine.close() method will be called, closing all registered pipes.

      Specified by:
      stopRunning in interface IManagable
      See Also:
    • toString

      public String toString()
      toString in class Object
    • waitForNoMessagesInProcess

      public void waitForNoMessagesInProcess() throws InterruptedException
    • getBeanName

      public String getBeanName()
      Specified by:
      getBeanName in interface org.springframework.beans.factory.NamedBean
    • setName

      public void setName(String name)
      name of the adapter
      Specified by:
      setName in interface INamedObject
    • getName

      @JmxAttribute(description="Name of the Adapter") public String getName()
      Specified by:
      getName in interface IConfigurationAware
      Specified by:
      getName in interface INamedObject
    • setDescription

      public void setDescription(String description)
      some functional description of the Adapter
    • setAutoStart

      public void setAutoStart(boolean autoStart)
      AutoStart indicates that the adapter should be started when the configuration is started.
      Default value
    • setReplaceNullMessage

      public void setReplaceNullMessage(boolean b)
      If true a null message is replaced by an empty message
      Default value
    • setMessageKeeperSize

      public void setMessageKeeperSize(int size)
      number of message displayed in ibisconsole
      Default value
    • setMsgLogLevel

      public void setMsgLogLevel(org.frankframework.core.Adapter.MessageLogLevel level)
      Defines behaviour for logging messages. Configuration is done in the MSG appender in
      Default value
      INFO, unless overridden by property msg.log.level.default
    • setRequestReplyLogging

      @Deprecated public void setRequestReplyLogging(boolean requestReplyLogging)
    • setMsgLogHidden

      public void setMsgLogHidden(boolean b)
      If set to true, the length of the message is shown in the msg log instead of the content of the message
      Default value
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface IConfigurationAware
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • getConfigurationClassLoader

      public ClassLoader getConfigurationClassLoader()
      Description copied from interface: IScopeProvider
      This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.
      Specified by:
      getConfigurationClassLoader in interface IScopeProvider
      returns the ClassLoader created by the ClassLoaderManager.
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface IAdapter
    • isAutoStart

      public boolean isAutoStart()
      Specified by:
      isAutoStart in interface IAdapter
    • isReplaceNullMessage

      public boolean isReplaceNullMessage()
    • getMessageKeeperSize

      public int getMessageKeeperSize()
    • isMsgLogHidden

      public boolean isMsgLogHidden()
    • setTargetDesignDocument

      public void setTargetDesignDocument(String targetDesignDocument)
    • getTargetDesignDocument

      public String getTargetDesignDocument()
    • getConfiguration

      public Configuration getConfiguration()
      Specified by:
      getConfiguration in interface IAdapter
    • getLastMessageProcessingState

      public String getLastMessageProcessingState()
    • setConfigurationMetrics

      public void setConfigurationMetrics(MetricsInitializer configurationMetrics)
    • isConfigurationSucceeded

      public boolean isConfigurationSucceeded()
    • getTaskExecutor

      public org.springframework.core.task.TaskExecutor getTaskExecutor()
    • setTaskExecutor

      public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)