Package org.frankframework.jdbc
Class JdbcTransactionalStorage<S extends Serializable>
java.lang.Object
org.frankframework.jdbc.JdbcFacade
org.frankframework.jdbc.AbstractJdbcMessageBrowser<S>
org.frankframework.jdbc.JdbcTableMessageBrowser<S>
org.frankframework.jdbc.JdbcTransactionalStorage<S>
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IMessageBrowser<S>,IScopeProvider,ITransactionalStorage<S>,IXAEnabled,NameAware,ConfigurableLifecycle,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
DummyTransactionalStorage,MessageStoreSender
public class JdbcTransactionalStorage<S extends Serializable>
extends JdbcTableMessageBrowser<S>
implements ITransactionalStorage<S>
Implements a message log (
Message log: A message log writes messages in persistent storage for logging purposes. When a message log appears in a receiver, it also ensures that the same message is only processed once, even if a related pushing listener receives the same message multiple times.
Error store: Appears in a receiver or sender pipe to store messages that could not be processed. Storing a message in the error store is the last resort of the Frank!Framework. Many types of listeners and senders offer a retry mechanism. Only if several tries have failed, then an optional transaction is not rolled back and the message is stored in the error store. Users can retry messages in an error store using the Frank!Console. When this is done, the message is processed in the same way as messages received from the original source.
How does a message log or error store see duplicate messages? The message log or error store always appears in combination with a sender or listener. This sender or listener determines a key based on the sent or received message. Messages with the same key are considered to be the same.
Storage structure is defined in /IAF_util/IAF_DatabaseChangelog.xml. If these database objects do not exist, the Frank!Framework will try to create them.
JdbcMessageLog) or error store (JdbcErrorStorage) that uses database
table IBISSTORE. A MessageStoreSender and MessageStoreListener
pair implicitly includes a message log and an error store.
If you have a MessageStoreSender and MessageStoreListener
pair it is superfluous to add a JdbcMessageLog or JdbcErrorStorage
within the same sender pipe or the same receiver.
Message log: A message log writes messages in persistent storage for logging purposes. When a message log appears in a receiver, it also ensures that the same message is only processed once, even if a related pushing listener receives the same message multiple times.
Error store: Appears in a receiver or sender pipe to store messages that could not be processed. Storing a message in the error store is the last resort of the Frank!Framework. Many types of listeners and senders offer a retry mechanism. Only if several tries have failed, then an optional transaction is not rolled back and the message is stored in the error store. Users can retry messages in an error store using the Frank!Console. When this is done, the message is processed in the same way as messages received from the original source.
How does a message log or error store see duplicate messages? The message log or error store always appears in combination with a sender or listener. This sender or listener determines a key based on the sent or received message. Messages with the same key are considered to be the same.
Storage structure is defined in /IAF_util/IAF_DatabaseChangelog.xml. If these database objects do not exist, the Frank!Framework will try to create them.
- Since:
- 4.1
- Author:
- Gerrit van Brakel, Jaco de Groot
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.frankframework.core.IMessageBrowser
IMessageBrowser.HideMethod, IMessageBrowser.SortOrder, IMessageBrowser.StorageType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected static final intprotected static final intprotected static final intprotected Stringprotected org.springframework.transaction.PlatformTransactionManagerFields inherited from class org.frankframework.jdbc.JdbcTableMessageBrowser
useIndexHintFields inherited from class org.frankframework.jdbc.AbstractJdbcMessageBrowser
checkCorrelationIdQuery, checkMessageIdQuery, CONTROL_PROPERTY_PREFIX, deleteQuery, getMessageCountQuery, PROPERTY_ASSUME_PRIMARY_KEY_UNIQUE, PROPERTY_USE_PARAMETERS, selectContextQuery, selectDataQueryFields inherited from class org.frankframework.jdbc.JdbcFacade
logFields inherited from interface org.frankframework.core.ITransactionalStorage
MAXCOMMENTLENFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates a connection, checks if the table is existing and creates it when necessaryconsumeMessage(String storageKey) Retrieves and deletes the message.protected voidcreateQueryTexts(IDbmsSupport dbmsSupport) protected voidcreateStorage(Connection conn, Statement stmt, IDbmsSupport dbmsSupport) Acutaly creates storage.protected Stringprotected Stringvoidinitialize(IDbmsSupport dbmsSupport) Checks if table exists, and creates when necessary.protected RawMessageWrapper<S> retrieveObject(String storageKey, ResultSet rs, int columnIndex) voidsetBlobsCompressed(boolean b) If set totrue, the messages are stored compressedvoidsetCheckTable(boolean b) If set totrue, checks are performed if the table exists and is properly createdvoidsetCreateTable(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.protected voidsetDataTypes(IDbmsSupport dbmsSupport) change datatypes used for specific database vendor.voidsetDateFieldType(String string) The type of the column the timestamps are stored invoidsetHostField(String hostField) The name of the column that stores the hostname of the servervoidsetKeyFieldType(String string) The type of the column that contains the primary key of the tablevoidsetMessageFieldType(String string) The type of the column message themselves are stored invoidsetOnlyStoreWhenMessageIdUnique(boolean onlyStoreWhenMessageIdUnique) If set totrue, the message is stored only if the MessageId is not present in the store yet.protected voidvoidsetRetention(int retention) The time (in days) to keep the record in the database before making it eligible for deletion by a cleanup process. when set to -1, the record will live on forevervoidsetSchemaOwner4Check(String string) Schema owner to be used to check the databasevoidsetSequenceName(String string) The name of the sequence used to generate the primary key, for DBMSes that use sequences, like OraclevoidSet the slotId, an identifier to keep separate the messages inserted by different JdbcTransactionalStorage instances.voidsetSlotIdField(String string) The name of the column slotids are stored invoidsetStoreFullMessage(boolean storeFullMessage) If set totrue, the full message is stored with the log.voidsetTextFieldType(String string) The type of the columns messageId and correlationId, slotId and comments are stored in.voidPossible values areE(error store),M(message store),L(message log for Pipe) orA(message log for Receiver).
Receiver will always set type toEfor errorStorage and always set type toAfor messageLog.voidsetTypeField(String typeField) The name of the column types are stored invoidstart()Prepares the object for operation.storeMessage(String messageId, String correlationId, Date receivedDate, String comments, String label, S message) Store the message, returns storageKey.storeMessage(Connection conn, String messageId, String correlationId, Date receivedDate, String comments, String label, S message) Stores a message in the database and retrieves the value of the primary key for the record just inserted.protected StringstoreMessageInDatabase(Connection conn, String messageId, String correlationId, Timestamp receivedDateTime, String comments, String label, S message) Methods inherited from class org.frankframework.jdbc.JdbcTableMessageBrowser
createSelector, getFromClause, getPhysicalDestinationName, getSelectListQuery, getStorageFields, provideFirstRowsHintAfterFirstKeyword, provideIndexHintAfterFirstKeyword, provideTrailingFirstRowsHint, setIndexName, setTableNameMethods inherited from class org.frankframework.jdbc.AbstractJdbcMessageBrowser
applyStandardParameters, applyStandardParameters, browseMessage, containsCorrelationId, containsMessageId, copyFacadeSettings, deleteMessage, getContext, getDatasource, getIterator, getIterator, getMessageCount, getWhereClause, setCommentField, setCorrelationIdField, setDateField, setExpiryDateField, setIdField, setKeyField, setLabelField, setMessageField, setOrder, setPrefixMethods inherited from class org.frankframework.jdbc.JdbcFacade
getConnection, getConnectionWithTimeout, getDatasourceName, getDbmsSupport, getPassword, isConnectionsArePooled, isRunning, isTransacted, setAuthAlias, setConnectionsArePooled, setDatasourceName, setDbmsSupportFactory, setName, setPassword, setTransacted, setUsername, stopMethods 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.IMessageBrowser
browseMessage, containsCorrelationId, containsMessageId, deleteMessage, getContext, getHideMethod, getHideRegex, getIterator, getIterator, getMessageCount, getStorageFields, setHideMethod, setHideRegexMethods inherited from interface org.frankframework.core.ITransactionalStorage
getSlotId, getType, stopMethods inherited from interface org.frankframework.core.IXAEnabled
isTransactedMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Field Details
-
MAXIDLEN
protected static final int MAXIDLEN- See Also:
-
MAXCIDLEN
protected static final int MAXCIDLEN- See Also:
-
MAXLABELLEN
protected static final int MAXLABELLEN- See Also:
-
insertQuery
-
selectKeyForMessageQuery
-
txManager
protected org.springframework.transaction.PlatformTransactionManager txManager
-
-
Constructor Details
-
JdbcTransactionalStorage
public JdbcTransactionalStorage()
-
-
Method Details
-
getLogPrefix
- Overrides:
getLogPrefixin classAbstractJdbcMessageBrowser<S extends Serializable>
-
setOperationControls
protected void setOperationControls()- Overrides:
setOperationControlsin classJdbcTableMessageBrowser<S extends Serializable>
-
configure
Creates a connection, checks if the table is existing and creates it when necessary- Specified by:
configurein interfaceIConfigurable- Specified by:
configurein interfaceITransactionalStorage<S extends Serializable>- Overrides:
configurein classJdbcTableMessageBrowser<S extends Serializable>- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:ITransactionalStoragePrepares the object for operation. After this method is called the storeMessage() and retrieveMessage() methods may be called- Specified by:
startin interfaceConfigurableLifecycle- Specified by:
startin interfaceITransactionalStorage<S extends Serializable>- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Overrides:
startin classJdbcFacade
-
setDataTypes
change datatypes used for specific database vendor. -
createQueryTexts
- Overrides:
createQueryTextsin classJdbcTableMessageBrowser<S extends Serializable>- Throws:
ConfigurationException
-
initialize
Checks if table exists, and creates when necessary.- Throws:
JdbcExceptionSQLException
-
createStorage
protected void createStorage(Connection conn, Statement stmt, IDbmsSupport dbmsSupport) throws JdbcException Acutaly creates storage. Can be overridden in descender classes- Throws:
JdbcException
-
storeMessageInDatabase
@Nonnull protected String storeMessageInDatabase(Connection conn, String messageId, String correlationId, Timestamp receivedDateTime, String comments, String label, S message) throws IOException, SQLException, JdbcException, SenderException -
storeMessage
@Nonnull public String storeMessage(String messageId, String correlationId, Date receivedDate, String comments, String label, S message) throws SenderException Description copied from interface:ITransactionalStorageStore the message, returns storageKey. The messageId should be unique.- Specified by:
storeMessagein interfaceITransactionalStorage<S extends Serializable>- Throws:
SenderException
-
storeMessage
@Nonnull public String storeMessage(@Nonnull Connection conn, @Nonnull String messageId, @Nonnull String correlationId, @Nonnull Date receivedDate, @Nullable String comments, @Nullable String label, @Nonnull S message) throws SenderException Stores a message in the database and retrieves the value of the primary key for the record just inserted.- Parameters:
conn- the database connectionmessageId- the ID of the messagecorrelationId- the correlation ID of the messagereceivedDate- the date when the message was receivedcomments- additional comments for the message (optional)label- the label for the message (optional)message- the message object to be stored- Returns:
- the value of the primary key for the inserted record
- Throws:
SenderException- if there is an error storing the message
-
retrieveObject
protected RawMessageWrapper<S> retrieveObject(String storageKey, ResultSet rs, int columnIndex) throws JdbcException - Overrides:
retrieveObjectin classJdbcTableMessageBrowser<S extends Serializable>- Throws:
JdbcException
-
consumeMessage
Retrieves and deletes the message. This method should always run in an existing transaction.- Specified by:
consumeMessagein interfaceITransactionalStorage<S extends Serializable>- Throws:
ListenerException
-
getStorageRefKey
-
setSlotId
Set the slotId, an identifier to keep separate the messages inserted by different JdbcTransactionalStorage instances.
This field is optional, unless the attributeonlyStoreWhenMessageIdUniqueis set totrue.- Specified by:
setSlotIdin interfaceITransactionalStorage<S extends Serializable>- Overrides:
setSlotIdin classAbstractJdbcMessageBrowser<S extends Serializable>- Parameters:
string- TheslotIDvalue for this JdbcTransactionalStorage.
-
setType
Description copied from interface:ITransactionalStoragePossible values areE(error store),M(message store),L(message log for Pipe) orA(message log for Receiver).
Receiver will always set type toEfor errorStorage and always set type toAfor messageLog. SenderPipe will set type toLfor messageLog (when type isn't specified).
SeeMessageStoreSenderfor typeM.- Specified by:
setTypein interfaceITransactionalStorage<S extends Serializable>- Overrides:
setTypein classAbstractJdbcMessageBrowser<S extends Serializable>
-
setSlotIdField
The name of the column slotids are stored in- Overrides:
setSlotIdFieldin classAbstractJdbcMessageBrowser<S extends Serializable>- Default value
- SLOTID
-
setTypeField
The name of the column types are stored in- Overrides:
setTypeFieldin classAbstractJdbcMessageBrowser<S extends Serializable>- Default value
- TYPE
-
setHostField
The name of the column that stores the hostname of the server- Overrides:
setHostFieldin classAbstractJdbcMessageBrowser<S extends Serializable>- Default value
- HOST
-
setSequenceName
The name of the sequence used to generate the primary key, for DBMSes that use sequences, like Oracle- Default value
- seq_ibisstore
-
setCheckTable
public void setCheckTable(boolean b) If set totrue, checks are performed if the table exists and is properly created- Default value
- false
-
setCreateTable
@Deprecated(forRemoval=true, since="7.9.0") @ConfigurationWarning("if you want to create and maintain database tables, please enable Liquibase") public void setCreateTable(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.If set totrue, the table is created if it does not exist- Default value
- false
-
setMessageFieldType
The type of the column message themselves are stored in -
setKeyFieldType
The type of the column that contains the primary key of the table -
setDateFieldType
The type of the column the timestamps are stored in -
setTextFieldType
The type of the columns messageId and correlationId, slotId and comments are stored in. N.B.(100)is appended for id's,(1000)is appended for comments. -
setBlobsCompressed
public void setBlobsCompressed(boolean b) If set totrue, the messages are stored compressed- Default value
- true
-
setRetention
public void setRetention(int retention) The time (in days) to keep the record in the database before making it eligible for deletion by a cleanup process. when set to -1, the record will live on forever- Default value
- 30
-
setSchemaOwner4Check
Schema owner to be used to check the database- Default value
- <current_schema> (only for oracle)
-
setStoreFullMessage
public void setStoreFullMessage(boolean storeFullMessage) If set totrue, the full message is stored with the log. Can be set tofalseto reduce table size, by avoiding to store the full message- Default value
- true
-
setOnlyStoreWhenMessageIdUnique
public void setOnlyStoreWhenMessageIdUnique(boolean onlyStoreWhenMessageIdUnique) If set totrue, the message is stored only if the MessageId is not present in the store yet.- Default value
- false
-