public class SimpleJdbcListener extends JdbcFacade implements IPullingListener<String>
HasStatistics.Action
Modifier and Type | Field and Description |
---|---|
protected Connection |
connection |
protected static String |
KEYWORD_SELECT_COUNT |
Constructor and Description |
---|
SimpleJdbcListener() |
Modifier and Type | Method and Description |
---|---|
void |
afterMessageProcessed(PipeLineResult processResult,
RawMessageWrapper<String> rawMessage,
PipeLineSession pipeLineSession)
Called to perform actions (like committing or sending a reply) after a message has been processed by the
Pipeline.
|
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 void |
execute(Connection conn,
String query) |
protected void |
execute(Connection conn,
String query,
String parameter) |
protected ResultSet |
executeQuery(Connection conn,
String query) |
Message |
extractMessage(RawMessageWrapper<String> rawMessage,
Map<String,Object> context)
Extracts data from message obtained from
IPullingListener.getRawMessage(Map) or
IPushingListener.wrapRawMessage(Object, PipeLineSession) . |
protected RawMessageWrapper<String> |
getRawMessage(Connection conn,
Map<String,Object> threadContext) |
RawMessageWrapper<String> |
getRawMessage(Map<String,Object> threadContext)
Retrieves messages from queue or other channel, but does no processing on it.
|
String |
getSelectQuery() |
boolean |
isTrace() |
void |
open()
Prepares the listener for receiving messages.
|
Map<String,Object> |
openThread()
Prepares a thread for receiving messages.
|
void |
setSelectQuery(String string)
count query that returns the number of available records.
|
void |
setTrace(boolean trace) |
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
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getDomain
protected static final String KEYWORD_SELECT_COUNT
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<String>
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<String>
ListenerException
public void close()
IListener
@Nonnull public Map<String,Object> openThread() throws ListenerException
IPullingListener
openThread
in interface IPullingListener<String>
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<String>
ListenerException
public RawMessageWrapper<String> 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<String>
ListenerException
protected RawMessageWrapper<String> getRawMessage(Connection conn, Map<String,Object> threadContext) throws ListenerException
ListenerException
public Message extractMessage(@Nonnull RawMessageWrapper<String> 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<String>
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
protected ResultSet executeQuery(Connection conn, String query) throws ListenerException
ListenerException
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<String> rawMessage, PipeLineSession pipeLineSession) throws ListenerException
IListener
afterMessageProcessed
in interface IListener<String>
ListenerException
protected void execute(Connection conn, String query) throws ListenerException
ListenerException
protected void execute(Connection conn, String query, String parameter) throws ListenerException
ListenerException
public void setSelectQuery(String string)
public String getSelectQuery()
public boolean isTrace()
public void setTrace(boolean trace)
Copyright © 2023 Frank!Framework. All rights reserved.