Package org.frankframework.jdbc
Class MessageStoreListener
java.lang.Object
org.frankframework.jdbc.JdbcFacade
org.frankframework.jdbc.JdbcListener<Serializable>
org.frankframework.jdbc.JdbcTableListener<Serializable>
org.frankframework.jdbc.MessageStoreListener
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IHasProcessState<Serializable>,IListener<Serializable>,IPeekableListener<Serializable>,IProvidesMessageBrowsers<Serializable>,IPullingListener<Serializable>,IScopeProvider,IXAEnabled,NameAware,ConfigurableLifecycle,ReceiverAware<Serializable>,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
Read messages from the IBISSTORE database table previously stored by a
See /IAF_util/IAF_DatabaseChangelog.xml for the structure of table IBISSTORE.
MessageStoreSender.
Example configuration:
<Receiver
name="03 MessageStoreReceiver"
numThreads="4"
transactionAttribute="Required"
pollInterval="1">
<MessageStoreListener
name="03 MessageStoreListener"
slotId="${instance.name}/TestMessageStore"
statusValueInProcess="I" />
</Receiver>
If you have a MessageStoreListener, failed messages are automatically kept in database
table IBISSTORE. Messages are also kept after successful processing. The state of a message
is distinguished by the TYPE field, as follows:
-
M: The message is new. From a functional perspective, it is in the message store. -
E: There was an error processing the message. From a functional perspective, it is in the error store. -
A: The message was successfully processed. From a functional perspective, it is in the message log.
MessageStoreListener acts as a message log and as an error store.
If you have it, you do not need to add
a JdbcErrorStorage or JdbcMessageLog within the same receiver.
See /IAF_util/IAF_DatabaseChangelog.xml for the structure of table IBISSTORE.
- Author:
- Jaco de Groot
-
Nested Class Summary
Nested classes/interfaces inherited from class org.frankframework.jdbc.JdbcListener
JdbcListener.MessageFieldType -
Field Summary
Fields inherited from class org.frankframework.jdbc.JdbcListener
ADDITIONAL_QUERY_FIELDS_KEY, connectionFields inherited from class org.frankframework.jdbc.JdbcFacade
logFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IMessageBrowser<Serializable> augmentMessageBrowser(IMessageBrowser<Serializable> browser) voidConfigure this component.extractMessage(RawMessageWrapper<Serializable> rawMessageWrapper, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession).protected RawMessageWrapper<Serializable> This method returns aMessageWrappercontaining contents of the message stored in the database.voidgetMessageBrowser(ProcessState state) returns abrowserof messages that are in ProcessState 'state', and are stored in a storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration).voidsetBlobSmartGet(boolean b) Controls automatically whether blobdata is stored compressed and/or serialized in the database.voidsetCommentField(String commentField) (optional) Field used to store the reason of the last change of thestatusFieldvoidsetCorrelationIdField(String fieldname) Field containing thecorrelationId.voidsetKeyField(String fieldname) Primary key field of the table, used to identify and differentiate messages.voidsetMessageField(String fieldname) Field containing the message datavoidsetMessageFieldType(JdbcListener.MessageFieldType fieldtype) Type of the field containing the message datavoidsetMessageIdField(String fieldname) Field containing themessageId.voidsetMoveToMessageLog(boolean moveToMessageLog) Move to messageLog after processing, as the message is already stored in the ibisstore only some fields need to be updated.voidsetSessionKeys(String sessionKeys) Comma separated list of sessionKey's to be read together with the message.voidIdentifier for this servicevoidsetStatusField(String fieldname) Field containing the status of the message.voidsetStatusValueAvailable(String string) Value of statusField indicating row is available to be processed.voidsetStatusValueError(String string) Value ofstatusFieldindicating the processing of the row resulted in an errorvoidsetStatusValueHold(String string) Value of status field indicating message is on Hold, temporarily.voidsetStatusValueInProcess(String string) Value of status field indicating is being processed.voidsetStatusValueProcessed(String string) Value of status field indicating row is processed OKvoidsetTableName(String string) Name of the table to be usedvoidsetTimestampField(String fieldname) (optional) Field used to store the date and time of the last change of thestatusFieldMethods inherited from class org.frankframework.jdbc.JdbcTableListener
changeProcessState, createUpdateStatusQuery, getPhysicalDestinationName, getStatusValue, getStorageType, setMaxCommentLength, setOrderField, setSelectCondition, setTableAlias, verifyFieldNotInQueryMethods inherited from class org.frankframework.jdbc.JdbcListener
addAdditionalQueryFieldsToSession, addAdditionalValuesToMessageWrapper, afterMessageProcessed, changeProcessState, closeThread, convertQuery, execute, getKeyFromRawMessage, getRawMessage, getRawMessage, getUpdateStatusQuery, hasRawMessageAvailable, hasRawMessageAvailable, knownProcessStates, openThread, setAdditionalFields, setBlobCharset, setBlobsCompressed, setPeekQuery, setPeekUntransacted, setSelectQuery, setSqlDialect, setUpdateStatusQuery, start, stop, targetProcessStatesMethods inherited from class org.frankframework.jdbc.JdbcFacade
getConnection, getConnectionWithTimeout, getDatasource, getDatasourceName, getDbmsSupport, getLogPrefix, getPassword, isConnectionsArePooled, isRunning, isTransacted, setAuthAlias, setConnectionsArePooled, setDatasourceName, setDbmsSupportFactory, setName, setPassword, setTransacted, setUsernameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.lifecycle.ConfigurableLifecycle
getPhase, isAutoStartup, isConfiguredMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.IHasProcessState
changeProcessState, knownProcessStates, targetProcessStatesMethods inherited from interface org.frankframework.core.IPeekableListener
isPeekUntransactedMethods inherited from interface org.frankframework.receivers.ReceiverAware
getReceiver, setReceiverMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
MessageStoreListener
public MessageStoreListener()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classJdbcTableListener<Serializable>- Throws:
ConfigurationException- in case it was not able to configure the component.
-
extractSessionKeyList
public void extractSessionKeyList() -
extractRawMessage
Description copied from class:JdbcListenerThis method returns aMessageWrappercontaining contents of the message stored in the database.- Overrides:
extractRawMessagein classJdbcListener<Serializable>- Parameters:
rs- JDBCResultSetfrom which to extract message data.- Returns:
- Either a
Stringbeing the message key, or aMessageWrapper. The message key asStringis returned ifJdbcListener.messageField,JdbcListener.messageIdFieldandJdbcListener.correlationIdFieldall are not set. IfJdbcListener.messageIdFieldand / orJdbcListener.correlationIdFieldare set butJdbcListener.messageFieldis not, then the message key is returned as value of aMessagewrapped in aMessageWrapper. Otherwise the message is loaded from thersparameter and returned wrapped in aMessageWrapper. - Throws:
JdbcException- If loading the message resulted in a database exception.
-
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<Serializable> rawMessageWrapper, @Nonnull Map<String, Object> context) throws ListenerExceptionDescription copied from interface:IListenerExtracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession). May also extract other parameters from the message and put those into the context.- Specified by:
extractMessagein interfaceIListener<Serializable>- Overrides:
extractMessagein classJdbcListener<Serializable>- Parameters:
rawMessageWrapper- TheRawMessageWrapperfrom which to extract theMessage.context- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor adapter. - Throws:
ListenerException
-
augmentMessageBrowser
protected IMessageBrowser<Serializable> augmentMessageBrowser(IMessageBrowser<Serializable> browser) -
getMessageBrowser
Description copied from interface:IProvidesMessageBrowsersreturns abrowserof messages that are in ProcessState 'state', and are stored in a storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration).- Specified by:
getMessageBrowserin interfaceIProvidesMessageBrowsers<Serializable>- Overrides:
getMessageBrowserin classJdbcTableListener<Serializable>
-
getSelectCondition
-
setSlotId
Identifier for this service -
setSessionKeys
Comma separated list of sessionKey's to be read together with the message. Please note: correspondingMessageStoreSendermust have the same value for this attribute -
setTableName
Description copied from class:JdbcTableListenerName of the table to be used- Overrides:
setTableNamein classJdbcTableListener<Serializable>
-
setKeyField
Description copied from class:JdbcListenerPrimary key field of the table, used to identify and differentiate messages. NB: there should be an index on this field!- Overrides:
setKeyFieldin classJdbcListener<Serializable>
-
setMessageField
Description copied from class:JdbcListenerField containing the message data- Overrides:
setMessageFieldin classJdbcListener<Serializable>
-
setMessageIdField
Description copied from class:JdbcListenerField containing themessageId. NB: If this column is not set the default (primary key)keyFieldwill be used as messageId!- Overrides:
setMessageIdFieldin classJdbcListener<Serializable>
-
setCorrelationIdField
Description copied from class:JdbcListenerField containing thecorrelationId. NB: If this column is not set, themessageIdandcorrelationIdwill be the same!- Overrides:
setCorrelationIdFieldin classJdbcListener<Serializable>
-
setMessageFieldType
Description copied from class:JdbcListenerType of the field containing the message data- Overrides:
setMessageFieldTypein classJdbcListener<Serializable>
-
setBlobSmartGet
Description copied from class:JdbcListenerControls automatically whether blobdata is stored compressed and/or serialized in the database. N.B. When set true, then the BLOB will be converted into a string- Overrides:
setBlobSmartGetin classJdbcListener<Serializable>
-
setStatusField
Description copied from class:JdbcTableListenerField containing the status of the message. NB: For optimal performance, an index should exist that starts with this field, followed by all fields that are used with a fixed value in the select condition, and end with theorderField.- Overrides:
setStatusFieldin classJdbcTableListener<Serializable>
-
setTimestampField
Description copied from class:JdbcTableListener(optional) Field used to store the date and time of the last change of thestatusField- Overrides:
setTimestampFieldin classJdbcTableListener<Serializable>
-
setCommentField
Description copied from class:JdbcTableListener(optional) Field used to store the reason of the last change of thestatusField- Overrides:
setCommentFieldin classJdbcTableListener<Serializable>
-
setStatusValueAvailable
Value of statusField indicating row is available to be processed. If set empty, any row not having any of the other status values is considered available.- Overrides:
setStatusValueAvailablein classJdbcTableListener<Serializable>- Default value
M
-
setStatusValueInProcess
Value of status field indicating is being processed. Set toIif database has no SKIP LOCKED functionality, the Receiver cannot be set toRequiredorRequiresNew, or to support programmatic retry.- Overrides:
setStatusValueInProcessin classJdbcTableListener<Serializable>
-
setStatusValueError
Description copied from class:JdbcTableListenerValue ofstatusFieldindicating the processing of the row resulted in an error- Overrides:
setStatusValueErrorin classJdbcTableListener<Serializable>
-
setStatusValueProcessed
Description copied from class:JdbcTableListenerValue of status field indicating row is processed OK- Overrides:
setStatusValueProcessedin classJdbcTableListener<Serializable>
-
setStatusValueHold
Value of status field indicating message is on Hold, temporarily. If required, suggested value isH.- Overrides:
setStatusValueHoldin classJdbcTableListener<Serializable>
-
setMoveToMessageLog
public void setMoveToMessageLog(boolean moveToMessageLog) Move to messageLog after processing, as the message is already stored in the ibisstore only some fields need to be updated. When setfalse, messages are deleted after being processed- Default value
true
-