pub struct SqlEndpointConfig {Show 37 fields
pub db_url: String,
pub max_connections: Option<u32>,
pub min_connections: Option<u32>,
pub idle_timeout_secs: Option<u64>,
pub max_lifetime_secs: Option<u64>,
pub query: String,
pub source_path: Option<String>,
pub output_type: SqlOutputType,
pub placeholder: char,
pub use_placeholder: bool,
pub noop: bool,
pub in_separator: String,
pub always_populate_statement: bool,
pub allow_named_parameters: bool,
pub fetch_size: Option<u32>,
pub transaction_mode: TransactionMode,
pub delay_ms: u64,
pub initial_delay_ms: u64,
pub max_messages_per_poll: Option<i32>,
pub on_consume: Option<String>,
pub on_consume_failed: Option<String>,
pub on_consume_batch_complete: Option<String>,
pub route_empty_result_set: bool,
pub use_iterator: bool,
pub expected_update_count: Option<i64>,
pub break_batch_on_consume_fail: bool,
pub bridge_error_handler: bool,
pub repeat_count: Option<u32>,
pub processing_strategy: ProcessingStrategy,
pub poll_strategy: PollStrategy,
pub batch: bool,
pub use_message_body_for_sql: bool,
pub ssl_mode: Option<String>,
pub ssl_root_cert: Option<String>,
pub ssl_cert: Option<String>,
pub ssl_key: Option<String>,
pub retry: NetworkRetryPolicy,
/* private fields */
}Expand description
Configuration for SQL component endpoints.
URI format: sql:<query>?db_url=<url>¶m1=val1¶m2=val2
The query can be inline SQL or a file reference with file: prefix:
sql:SELECT * FROM users?db_url=...- inline SQLsql:file:/path/to/query.sql?db_url=...- read SQL from file
Note on file-based queries (SQL-014): When the query path starts with file:,
the file is NOT read synchronously during from_uri(). Instead, the file path is
stored in source_path and the query is resolved asynchronously via resolve_file_query()
during async initialization (producer pool init or consumer start). This avoids
blocking I/O in the synchronous URI parsing path.
Security note: Debug implementation redacts the db_url (which may contain credentials)
and ssl_key path. Use redact_db_url() for safe logging of database URLs.
Fields§
§db_url: StringDatabase connection URL (required).
max_connections: Option<u32>Maximum connections in the pool. None = use global default.
min_connections: Option<u32>Minimum connections in the pool. None = use global default.
idle_timeout_secs: Option<u64>Idle timeout in seconds. None = use global default.
max_lifetime_secs: Option<u64>Maximum connection lifetime in seconds. None = use global default.
query: StringThe SQL query (from URI path or file).
source_path: Option<String>Path to the file containing the SQL query (when using file: prefix).
output_type: SqlOutputTypeOutput type for query results. Default: SelectList.
placeholder: charPlaceholder character for parameters. Default: ‘#’.
use_placeholder: boolIf true, process parameter placeholders in queries. Default: true.
noop: boolIf true, don’t execute the query (dry run). Default: false.
in_separator: StringSeparator for IN clause expansion. Default: “, “.
always_populate_statement: boolIf true, always bind parameters even if the exchange body is null/empty (uses empty defaults). Default: false.
allow_named_parameters: boolIf true, recognize :name style placeholders and map them from exchange
headers or body fields. Default: true.
fetch_size: Option<u32>Fetch size hint for query results. None = driver default.
transaction_mode: TransactionModeTransaction mode for SQL operations. Default: Auto.
delay_ms: u64Delay between polls in milliseconds. Default: 500.
initial_delay_ms: u64Initial delay before first poll in milliseconds. Default: 1000.
max_messages_per_poll: Option<i32>Maximum messages per poll.
on_consume: Option<String>SQL to execute after consuming each message.
on_consume_failed: Option<String>SQL to execute if consumption fails.
on_consume_batch_complete: Option<String>SQL to execute after consuming a batch.
route_empty_result_set: boolRoute empty result sets. Default: false.
use_iterator: boolUse iterator for results. Default: true.
expected_update_count: Option<i64>Expected number of rows affected.
break_batch_on_consume_fail: boolBreak batch on consume failure. Default: false.
bridge_error_handler: boolBridge poll errors into route error handling. Default: false.
repeat_count: Option<u32>When set, the consumer only polls up to repeat_count times before stopping.
None = poll indefinitely (default).
processing_strategy: ProcessingStrategyProcessing strategy for consumer. Default: Direct.
poll_strategy: PollStrategyPoll strategy for consumer. Default: Sequential.
batch: boolEnable batch mode. Default: false.
use_message_body_for_sql: boolUse message body for SQL. Default: false.
ssl_mode: Option<String>SSL mode for the connection. None = use global default.
ssl_root_cert: Option<String>Path to SSL root certificate. None = use global default.
ssl_cert: Option<String>Path to SSL client certificate. None = use global default.
ssl_key: Option<String>Path to SSL client key. None = use global default.
retry: NetworkRetryPolicyRetry policy for transient database connection failures.
Implementations§
Source§impl SqlEndpointConfig
impl SqlEndpointConfig
Sourcepub fn apply_defaults(&mut self, defaults: &SqlGlobalConfig)
pub fn apply_defaults(&mut self, defaults: &SqlGlobalConfig)
Apply defaults from global config, filling None fields without overriding.
Sourcepub fn resolve_defaults(&mut self)
pub fn resolve_defaults(&mut self)
Resolve any remaining None fields with built-in defaults.
Sourcepub async fn resolve_file_query(&mut self) -> Result<(), CamelError>
pub async fn resolve_file_query(&mut self) -> Result<(), CamelError>
Asynchronously read the SQL query from the file referenced by source_path.
This is the async replacement for the blocking std::fs::read_to_string that
was previously called in from_uri(). Must be invoked during async init
(producer pool init or consumer start) — never in a synchronous context.
After this call, self.query contains the file content (trimmed) and
self.source_path is cleared to prevent re-reading.
Trait Implementations§
Source§impl Clone for SqlEndpointConfig
impl Clone for SqlEndpointConfig
Source§fn clone(&self) -> SqlEndpointConfig
fn clone(&self) -> SqlEndpointConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SqlEndpointConfig
impl Debug for SqlEndpointConfig
Source§impl UriConfig for SqlEndpointConfig
impl UriConfig for SqlEndpointConfig
Source§fn scheme() -> &'static str
fn scheme() -> &'static str
Source§fn from_uri(uri: &str) -> Result<Self, CamelError>
fn from_uri(uri: &str) -> Result<Self, CamelError>
Source§fn from_components(parts: UriComponents) -> Result<Self, CamelError>
fn from_components(parts: UriComponents) -> Result<Self, CamelError>
Source§fn validate(self) -> Result<Self, CamelError>
fn validate(self) -> Result<Self, CamelError>
Auto Trait Implementations§
impl Freeze for SqlEndpointConfig
impl RefUnwindSafe for SqlEndpointConfig
impl Send for SqlEndpointConfig
impl Sync for SqlEndpointConfig
impl Unpin for SqlEndpointConfig
impl UnsafeUnpin for SqlEndpointConfig
impl UnwindSafe for SqlEndpointConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more