M
- MessageWrapper or key. Key is also used as messageIdpublic class JdbcListener<M> extends JdbcFacade implements IPeekableListener<M>, IHasProcessState<M>
Modifier and Type | Class and Description |
---|---|
static class |
JdbcListener.MessageFieldType |
HasStatistics.Action
Modifier and Type | Field and Description |
---|---|
protected Connection |
connection |
Constructor and Description |
---|
JdbcListener() |
Modifier and Type | Method and Description |
---|---|
void |
afterMessageProcessed(PipeLineResult processResult,
RawMessageWrapper<M> rawMessage,
PipeLineSession pipeLineSession)
Called to perform actions (like committing or sending a reply) after a message has been processed by the
Pipeline.
|
protected RawMessageWrapper<M> |
changeProcessState(Connection connection,
RawMessageWrapper<M> rawMessage,
ProcessState toState,
String reason) |
RawMessageWrapper<M> |
changeProcessState(RawMessageWrapper<M> rawMessage,
ProcessState toState,
String reason)
Change the processState of the message to the specified state, if that state
is supported.
|
void |
close()
Close all resources used for listening.
|
void |
closeThread(Map<String,Object> threadContext)
Finalizes a message receiving thread.
|
void |
configure()
configure() is called once at startup of the framework in the configure() method
of the owner of this listener. |
protected String |
convertQuery(String query) |
protected boolean |
execute(Connection conn,
String query,
String... parameters) |
Message |
extractMessage(RawMessageWrapper<M> rawMessage,
Map<String,Object> context)
Extracts data from message obtained from
IPullingListener.getRawMessage(Map) or
IPushingListener.wrapRawMessage(Object, PipeLineSession) . |
protected MessageWrapper<M> |
extractRawMessage(ResultSet rs)
This method returns a
MessageWrapper containing contents of the message stored in the database. |
protected String |
getKeyFromRawMessage(RawMessageWrapper<M> rawMessage) |
protected RawMessageWrapper<M> |
getRawMessage(Connection conn,
Map<String,Object> threadContext) |
RawMessageWrapper<M> |
getRawMessage(Map<String,Object> threadContext)
Retrieves messages from queue or other channel, but does no processing on it.
|
String |
getUpdateStatusQuery(ProcessState state) |
boolean |
hasRawMessageAvailable() |
protected boolean |
hasRawMessageAvailable(Connection conn) |
Set<ProcessState> |
knownProcessStates()
Provides the set of ProcessStates used by this listener.
|
void |
open()
Prepares the listener for receiving messages.
|
Map<String,Object> |
openThread()
Prepares a thread for receiving messages.
|
void |
setBlobCharset(String string)
Deprecated.
|
void |
setBlobsCompressed(boolean b)
Controls whether BLOB is considered stored compressed in the database
|
void |
setBlobSmartGet(boolean b)
Controls automatically whether blobdata is stored compressed and/or serialized in the database.
|
void |
setCorrelationIdField(String fieldname)
Field containing the correlationId
|
void |
setKeyField(String fieldname)
Primary key field of the table, used to identify messages.
|
void |
setMessageField(String fieldname)
Field containing the message data
|
void |
setMessageFieldType(JdbcListener.MessageFieldType value)
Type of the field containing the message data
|
void |
setMessageIdField(String fieldname)
Field containing the message Id
|
void |
setPeekQuery(String string)
(only used when
peekUntransacted =true ) peek query to determine if the select query should be executed. |
void |
setPeekUntransacted(boolean b)
when true, then PollingListener container will execute getRawMessage() only when hasRawMessageAvailable() has returned true.
|
protected void |
setSelectQuery(String string) |
void |
setSqlDialect(String string)
If set, the SQL dialect in which the queries are written and should be translated from to the actual SQL dialect
|
void |
setTrace(boolean trace) |
protected void |
setUpdateStatusQuery(ProcessState state,
String query) |
Map<ProcessState,Set<ProcessState>> |
targetProcessStates()
Provides the set of ProcessStates that a message in the specified state can be moved to, e.g.
|
getAuthAlias, getConnection, getConnectionWithTimeout, getDatasource, getDatasourceInfo, getDatasourceName, getDbmsSupport, getLogPrefix, getPassword, getPhysicalDestinationName, getUsername, isConnectionsArePooled, isTransacted, iterateOverStatistics, setAuthAlias, setConnectionsArePooled, setDatasourceName, setDbmsSupportFactory, setJmsRealm, setPassword, setTransacted, setUsername
getContext, getJndiEnv, setAuthentication, setCredentials, setInitialContextFactoryName, setJndiAuthAlias, setJndiContextPrefix, setJndiProperties, setName, setPrincipal, setProviderURL, setSecurityProtocol, setUrlPkgPrefixes, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isPeekUntransacted
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getDomain
protected Connection connection
public void configure() throws ConfigurationException
IListener
configure()
is called once at startup of the framework in the configure()
method
of the owner of this listener.
Purpose of this method is to reduce creating connections to databases etc. in the IPullingListener.getRawMessage(Map)
method.
As much as possible class-instantiating should take place in the
configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface IListener<M>
configure
in class JdbcFacade
ConfigurationException
public void open() throws ListenerException
IListener
open()
is called once each time the listener is started.open
in interface IListener<M>
ListenerException
public void close()
IListener
@Nonnull public Map<String,Object> openThread() throws ListenerException
IPullingListener
openThread
in interface IPullingListener<M>
null
, must be a mutable map type.ListenerException
public void closeThread(@Nonnull Map<String,Object> threadContext) throws ListenerException
IPullingListener
IListener.close()
is called.closeThread
in interface IPullingListener<M>
ListenerException
public boolean hasRawMessageAvailable() throws ListenerException
hasRawMessageAvailable
in interface IPeekableListener<M>
ListenerException
protected boolean hasRawMessageAvailable(Connection conn) throws ListenerException
ListenerException
public RawMessageWrapper<M> getRawMessage(@Nonnull Map<String,Object> threadContext) throws ListenerException
IPullingListener
synchronized
.
Any thread-specific properties should be stored in and retrieved from the threadContext.
getRawMessage
in interface IPullingListener<M>
ListenerException
protected RawMessageWrapper<M> getRawMessage(Connection conn, Map<String,Object> threadContext) throws ListenerException
ListenerException
protected MessageWrapper<M> extractRawMessage(ResultSet rs) throws JdbcException
MessageWrapper
containing contents of the message stored in the database.rs
- JDBC ResultSet
from which to extract message data.String
being the message key, or a MessageWrapper
.
The message key as String
is returned if messageField
, messageIdField
and correlationIdField
all are not
set.
If messageIdField
and / or correlationIdField
are set but messageField
is not, then the
message key is returned as value of a Message
wrapped in a MessageWrapper
.
Otherwise the message is loaded from the rs
parameter and returned wrapped in a MessageWrapper
.JdbcException
- If loading the message resulted in a database exception.protected String getKeyFromRawMessage(RawMessageWrapper<M> rawMessage) throws ListenerException
ListenerException
public Message extractMessage(@Nonnull RawMessageWrapper<M> rawMessage, @Nonnull Map<String,Object> context) throws ListenerException
IListener
IPullingListener.getRawMessage(Map)
or
IPushingListener.wrapRawMessage(Object, PipeLineSession)
. May also extract
other parameters from the message and put those into the context.extractMessage
in interface IListener<M>
rawMessage
- The RawMessageWrapper
from which to extract the Message
.context
- Context to populate. Either a PipeLineSession
or a Map
threadContext depending on caller.Message
for adapter.ListenerException
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<M> rawMessage, PipeLineSession pipeLineSession) throws ListenerException
IListener
afterMessageProcessed
in interface IListener<M>
ListenerException
public Set<ProcessState> knownProcessStates()
IHasProcessState
knownProcessStates
in interface IHasProcessState<M>
public Map<ProcessState,Set<ProcessState>> targetProcessStates()
IHasProcessState
targetProcessStates
in interface IHasProcessState<M>
public RawMessageWrapper<M> changeProcessState(RawMessageWrapper<M> rawMessage, ProcessState toState, String reason) throws ListenerException
IHasProcessState
false
is returned.changeProcessState
in interface IHasProcessState<M>
ListenerException
protected RawMessageWrapper<M> changeProcessState(Connection connection, RawMessageWrapper<M> rawMessage, ProcessState toState, String reason) throws ListenerException
ListenerException
protected boolean execute(Connection conn, String query, String... parameters) throws ListenerException
ListenerException
protected String convertQuery(String query) throws JdbcException, SQLException
JdbcException
SQLException
protected void setUpdateStatusQuery(ProcessState state, String query)
public String getUpdateStatusQuery(ProcessState state)
protected void setSelectQuery(String string)
public void setPeekUntransacted(boolean b)
IPeekableListener
setPeekUntransacted
in interface IPeekableListener<M>
public void setPeekQuery(String string)
peekUntransacted
=true
) peek query to determine if the select query should be executed. Peek queries are, unlike select queries, executed without a transaction and without a rowlockpublic void setKeyField(String fieldname)
public void setMessageField(String fieldname)
public void setMessageFieldType(JdbcListener.MessageFieldType value)
public void setMessageIdField(String fieldname)
public void setCorrelationIdField(String fieldname)
public void setSqlDialect(String string)
public void setBlobsCompressed(boolean b)
@Deprecated public void setBlobCharset(String string)
public void setBlobSmartGet(boolean b)
public void setTrace(boolean trace)
Copyright © 2023 Frank!Framework. All rights reserved.