@UriEndpoint(scheme="sql", syntax="sql:query", consumerClass=SqlConsumer.class, label="database,sql") public class SqlEndpoint extends org.apache.camel.impl.DefaultPollingEndpoint
Constructor and Description |
---|
SqlEndpoint() |
SqlEndpoint(String uri,
org.apache.camel.Component component,
org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
String query) |
Modifier and Type | Method and Description |
---|---|
org.apache.camel.Consumer |
createConsumer(org.apache.camel.Processor processor) |
protected String |
createEndpointUri() |
org.apache.camel.Producer |
createProducer() |
DataSource |
getDataSource() |
String |
getDataSourceRef() |
org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate() |
int |
getMaxMessagesPerPoll() |
String |
getOnConsume() |
String |
getOnConsumeBatchComplete() |
String |
getOnConsumeFailed() |
String |
getOutputClass() |
String |
getOutputHeader() |
SqlOutputType |
getOutputType() |
int |
getParametersCount() |
SqlPrepareStatementStrategy |
getPrepareStatementStrategy() |
SqlProcessingStrategy |
getProcessingStrategy() |
String |
getQuery() |
char |
getSeparator() |
boolean |
isAllowNamedParameters() |
boolean |
isAlwaysPopulateStatement() |
boolean |
isBatch() |
boolean |
isNoop() |
boolean |
isSingleton() |
protected List<?> |
queryForList(ResultSet rs,
boolean allowMapToClass) |
protected Object |
queryForObject(ResultSet rs) |
void |
setAllowNamedParameters(boolean allowNamedParameters)
Whether to allow using named parameters in the queries.
|
void |
setAlwaysPopulateStatement(boolean alwaysPopulateStatement)
If enabled then the populateStatement method from org.apache.camel.component.sql.SqlPrepareStatementStrategy is always invoked,
also if there is no expected parameters to be prepared.
|
void |
setBatch(boolean batch)
Enables or disables batch mode
|
void |
setDataSource(DataSource dataSource)
Sets the DataSource to use to communicate with the database.
|
void |
setDataSourceRef(String dataSourceRef)
Sets the reference to a DataSource to lookup from the registry, to use for communicating with the database.
|
void |
setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) |
void |
setMaxMessagesPerPoll(int maxMessagesPerPoll)
Sets the maximum number of messages to poll
|
void |
setNoop(boolean noop)
If set, will ignore the results of the SQL query and use the existing IN message as the OUT message for the continuation of processing
|
void |
setOnConsume(String onConsume)
After processing each row then this query can be executed, if the Exchange was processed successfully, for example to mark the row as processed.
|
void |
setOnConsumeBatchComplete(String onConsumeBatchComplete)
After processing the entire batch, this query can be executed to bulk update rows etc.
|
void |
setOnConsumeFailed(String onConsumeFailed)
After processing each row then this query can be executed, if the Exchange failed, for example to mark the row as failed.
|
void |
setOutputClass(String outputClass)
Specify the full package and class name to use as conversion when outputType=SelectOne.
|
void |
setOutputHeader(String outputHeader)
Store the query result in a header instead of the message body.
|
void |
setOutputType(SqlOutputType outputType)
Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way:
a) If the query has only single column, then that JDBC Column object is returned.
|
void |
setParametersCount(int parametersCount)
If set greater than zero, then Camel will use this count value of parameters to replace instead of querying via JDBC metadata API.
|
void |
setPrepareStatementStrategy(SqlPrepareStatementStrategy prepareStatementStrategy)
Allows to plugin to use a custom org.apache.camel.component.sql.SqlPrepareStatementStrategy to control preparation of the query and prepared statement.
|
void |
setProcessingStrategy(SqlProcessingStrategy processingStrategy)
Allows to plugin to use a custom org.apache.camel.component.sql.SqlProcessingStrategy to execute queries when the consumer has processed the rows/batch.
|
void |
setQuery(String query)
Sets the SQL query to perform
|
void |
setSeparator(char separator)
The separator to use when parameter values is taken from message body (if the body is a String type), to be inserted at # placeholders.
|
configurePollingConsumer, configureProperties, configureScheduledPollConsumerProperties, doStart, doStop, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDelay, getInitialDelay, getPollStrategy, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, initConsumerProperties, isGreedy, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay
configureConsumer, createEndpointConfiguration, createExchange, createExchange, createExchange, createPollingConsumer, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExchangePattern, getId, getPollingConsumerQueueSize, hashCode, isLenientProperties, isPollingConsumerBlockWhenFull, isSynchronous, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExchangePattern, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
createConsumer
in interface org.apache.camel.Endpoint
createConsumer
in class org.apache.camel.impl.DefaultPollingEndpoint
Exception
public boolean isSingleton()
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
public String getQuery()
public void setQuery(String query)
public boolean isBatch()
public void setBatch(boolean batch)
public int getMaxMessagesPerPoll()
public void setMaxMessagesPerPoll(int maxMessagesPerPoll)
public SqlProcessingStrategy getProcessingStrategy()
public void setProcessingStrategy(SqlProcessingStrategy processingStrategy)
public SqlPrepareStatementStrategy getPrepareStatementStrategy()
public void setPrepareStatementStrategy(SqlPrepareStatementStrategy prepareStatementStrategy)
public String getOnConsume()
public void setOnConsume(String onConsume)
public String getOnConsumeFailed()
public void setOnConsumeFailed(String onConsumeFailed)
public String getOnConsumeBatchComplete()
public void setOnConsumeBatchComplete(String onConsumeBatchComplete)
public boolean isAllowNamedParameters()
public void setAllowNamedParameters(boolean allowNamedParameters)
public boolean isAlwaysPopulateStatement()
public void setAlwaysPopulateStatement(boolean alwaysPopulateStatement)
public char getSeparator()
public void setSeparator(char separator)
public SqlOutputType getOutputType()
public void setOutputType(SqlOutputType outputType)
public String getOutputClass()
public void setOutputClass(String outputClass)
public int getParametersCount()
public void setParametersCount(int parametersCount)
public boolean isNoop()
public void setNoop(boolean noop)
public String getOutputHeader()
public void setOutputHeader(String outputHeader)
public String getDataSourceRef()
public void setDataSourceRef(String dataSourceRef)
public DataSource getDataSource()
public void setDataSource(DataSource dataSource)
protected String createEndpointUri()
createEndpointUri
in class org.apache.camel.impl.DefaultEndpoint
protected List<?> queryForList(ResultSet rs, boolean allowMapToClass) throws SQLException
SQLException
protected Object queryForObject(ResultSet rs) throws SQLException
SQLException
Apache Camel