Package org.frankframework.core
Class Adapter
java.lang.Object
org.frankframework.core.Adapter
- All Implemented Interfaces:
IConfigurable
,IConfigurationAware
,IManagable
,INamedObject
,IScopeProvider
,HasStatistics
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.NamedBean
,org.springframework.context.ApplicationContextAware
@Category(BASIC)
@FrankDocGroup(OTHER)
public class Adapter
extends Object
implements IManagable, HasStatistics, org.springframework.beans.factory.NamedBean
The Adapter is the central manager in the framework. It has knowledge of both
An Adapter receives a specific type of messages and processes them. It has
If an adapter can receive its messages through multiple channels (e.g. RESTful HTTP requests, incoming files, etc), each channel appears as a separate
Adapters gather statistics about the messages they process.
Adapters can process messages in parallel. They are thread-safe.
Receiver
s as well as the PipeLine
and statistics.
The Adapter is the class that is responsible for configuring, initializing and
accessing/activating Receivers, Pipelines, statistics etc.
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.
- Author:
- Johan Verrips
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
send an error to the log and to the messagekeeper of the adaptervoid
addReceiver
(Receiver<?> receiver) Receives incoming messages.boolean
void
Instruct the adapter to configure itself.void
configureReceiver
(Receiver<?> receiver) formatErrorMessage
(String errorMessage, Throwable t, Message originalMessage, String messageID, INamedObject objectInError, long receivedTime) org.springframework.context.ApplicationContext
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.long
getLastExitIsTimeoutDate
(String pipeName) retrieve the date and time of the last message.the MessageKeeper is for keeping the lastmessageKeeperSize
messages available, for instance for displaying it in the webcontrolint
getName()
double
The number of messages for which processing ended unsuccessfully.int
double
Total of messages processedlong[]
Receiver<?>
getReceiverByName
(String receiverName) returns the runstate of the object.return the date and time since active Creation date: (19-02-2003 12:16:53)org.springframework.core.task.TaskExecutor
boolean
boolean
boolean
boolean
void
logToMessageLogWithMessageContentsOrSize
(org.apache.logging.log4j.Level level, String logMessage, String dataPrefix, Message data) processMessageDirect
(String messageId, Message message, PipeLineSession pipeLineSession) Direct call to the Adapter PipeLine, foregoing any listeners and receivers.processMessageWithExceptions
(String messageId, Message message, PipeLineSession pipeLineSession) This method does the real processing of messages by the adapter.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setAutoStart
(boolean autoStart) AutoStart indicates that the adapter should be started when the configuration is started.void
setConfiguration
(Configuration configuration) void
setConfigurationMetrics
(MetricsInitializer configurationMetrics) void
setDescription
(String description) some functional description of theAdapter
void
setErrorMessageFormatter
(IErrorMessageFormatter errorMessageFormatter) Formatter for errors that can occur in this adapter.void
setLastExitState
(String pipeName, long lastExitStateDate, String lastExitState) void
setMessageKeeperSize
(int size) number of message displayed in ibisconsolevoid
setMsgLogHidden
(boolean b) If set totrue
, the length of the message is shown in the msg log instead of the content of the messagevoid
Defines behaviour for logging messages.void
name of the adaptervoid
setPipeLine
(PipeLine pipeline) ThePipeLine
.void
setReplaceNullMessage
(boolean b) Iftrue
a null message is replaced by an empty messagevoid
setRequestReplyLogging
(boolean requestReplyLogging) Deprecated.void
setTargetDesignDocument
(String targetDesignDocument) void
setTaskExecutor
(org.springframework.core.task.TaskExecutor taskExecutor) void
Start the adapter.void
Stop theAdapter
and close all elements like receivers, Pipeline, pipes etc.toString()
void
protected void
send a warning to the log and to the messagekeeper of the adapter
-
Field Details
-
msgLog
protected org.apache.logging.log4j.Logger msgLog -
PROCESS_STATE_OK
- See Also:
-
PROCESS_STATE_ERROR
- See Also:
-
-
Constructor Details
-
Adapter
public Adapter()
-
-
Method Details
-
getAdapter
- Specified by:
getAdapter
in interfaceHasStatistics
-
configure
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 interfaceIConfigurable
- Throws:
ConfigurationException
- See Also:
-
configureReceiver
- Throws:
ConfigurationException
-
configurationSucceeded
public boolean configurationSucceeded() -
warn
send a warning to the log and to the messagekeeper of the adapter -
addErrorMessageToMessageKeeper
send an error to the log and to the messagekeeper of the adapter -
setLastExitState
-
getLastExitIsTimeoutDate
-
formatErrorMessage
-
getLastMessageDate
@JmxAttribute(description="The date/time of the last processed message") public String getLastMessageDate()retrieve the date and time of the last message. -
getLastMessageDateDate
-
getMessageKeeper
the MessageKeeper is for keeping the lastmessageKeeperSize
messages available, for instance for displaying it in the webcontrol- See Also:
-
getNumOfMessagesInError
The number of messages for which processing ended unsuccessfully. -
getNumOfMessagesInProcess
-
getNumOfMessagesStartProcessingByHour
public long[] getNumOfMessagesStartProcessingByHour() -
getNumOfMessagesProcessed
Total of messages processed- Returns:
- long total messages processed
-
getReceiverByName
-
getReceivers
-
getRunState
Description copied from interface:IManagable
returns the runstate of the object. Possible values are defined byRunState
.- Specified by:
getRunState
in interfaceIManagable
-
getRunStateAsString
-
getStatsUpSince
return the date and time since active Creation date: (19-02-2003 12:16:53)- Returns:
- String Date
-
getStatsUpSinceDate
-
logToMessageLogWithMessageContentsOrSize
-
processMessageDirect
public PipeLineResult processMessageDirect(String messageId, Message message, PipeLineSession pipeLineSession) Direct call to the Adapter PipeLine, foregoing any listeners and receivers. This method does an amount of setup which is otherwise done by theReceiver
.
This method does not throw any exceptions, and will always return aPipeLineResult
. If an error occurred, the error information is in thePipeLineResult
.- Parameters:
messageId
- ID of the messagemessage
-Message
to be processedpipeLineSession
-PipeLineSession
session in which message is to be processed- Returns:
- The
PipeLineResult
from processing the message, or indicating what error occurred.
-
processMessageWithExceptions
public PipeLineResult processMessageWithExceptions(String messageId, Message message, PipeLineSession pipeLineSession) throws ListenerException This method does the real processing of messages by the adapter. This method is to be called either from theReceiver
, or fromprocessMessageDirect(String, Message, PipeLineSession)
.
NB: This method expects most setup to already have been done by the caller! LoggingContext and masking of sensitive information is among things that should be set up by the caller.
This method will return aPipeLineResult
with results of the processing. This might indicate an error if the message could not be processed successfully. If there was an exception from thePipeLine
, aListenerException
might be thrown.- Parameters:
messageId
- ID of the messagemessage
-Message
to be processedpipeLineSession
-PipeLineSession
in which the message is to be processed- Returns:
PipeLineResult
with result from processing the message in thePipeLine
.- Throws:
ListenerException
- If there was an exception, throws aListenerException
.
-
addReceiver
Receives incoming messages. If an adapter can receive messages through multiple channels, then add a receiver for each channel. -
setErrorMessageFormatter
Formatter for errors that can occur in this adapter. -
setPipeLine
ThePipeLine
. -
getPipeLine
-
setConfiguration
-
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 theRunnable
interface. The actual starting is done in therun
method.- Specified by:
startRunning
in interfaceIManagable
- See Also:
-
stopRunning
public void stopRunning()Stop theAdapter
and close all elements like receivers, Pipeline, pipes etc. The adapter will call theIReceiver
tostopListening
Also the
PipeLine.stop()
method will be called, closing all registered pipes.- Specified by:
stopRunning
in interfaceIManagable
- See Also:
-
toString
-
waitForNoMessagesInProcess
- Throws:
InterruptedException
-
getBeanName
- Specified by:
getBeanName
in interfaceorg.springframework.beans.factory.NamedBean
-
setName
name of the adapter- Specified by:
setName
in interfaceINamedObject
-
getName
- Specified by:
getName
in interfaceIConfigurationAware
- Specified by:
getName
in interfaceINamedObject
-
setDescription
some functional description of theAdapter
-
setAutoStart
public void setAutoStart(boolean autoStart) AutoStart indicates that the adapter should be started when the configuration is started.- Default value
true
-
setReplaceNullMessage
public void setReplaceNullMessage(boolean b) Iftrue
a null message is replaced by an empty message- Default value
false
-
setMessageKeeperSize
public void setMessageKeeperSize(int size) number of message displayed in ibisconsole- Default value
- 10
-
setMsgLogLevel
Defines behaviour for logging messages. Configuration is done in the MSG appender in log4j4ibis.properties.- Default value
INFO
, unless overridden by propertymsg.log.level.default
-
setRequestReplyLogging
Deprecated. -
setMsgLogHidden
public void setMsgLogHidden(boolean b) If set totrue
, the length of the message is shown in the msg log instead of the content of the message- Default value
false
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
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 interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getDescription
-
isAutoStart
public boolean isAutoStart() -
isReplaceNullMessage
public boolean isReplaceNullMessage() -
getMessageKeeperSize
public int getMessageKeeperSize() -
isMsgLogHidden
public boolean isMsgLogHidden() -
setTargetDesignDocument
-
getTargetDesignDocument
-
getConfiguration
-
getLastMessageProcessingState
-
setConfigurationMetrics
-
isConfigurationSucceeded
public boolean isConfigurationSucceeded() -
getTaskExecutor
public org.springframework.core.task.TaskExecutor getTaskExecutor() -
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor) -
getComposedHideRegex
-
getComposedHideRegexPattern
-