You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marco Crivellaro <ma...@gmail.com> on 2013/07/31 10:18:16 UTC

camel-sql, connection test required?

Hi all,
when using camel-sql should connection pooling and connection test be
implemented?
I am building a camel based application which will run as a daemon and might
write the database once every few days. This means between writes the
connection to the database (mysql) might timeout. Is camel testing
connection before writing to the database or will it throw an exception in
case the connection runs in timeout?


Thanks,
Marco



--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-connection-test-required-tp5736549.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-sql, connection test required?

Posted by Marco Crivellaro <ma...@gmail.com>.
Thanks for pointing that out, I'll have a look at it.



--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-connection-test-required-tp5736549p5736624.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-sql, connection test required?

Posted by Christian Müller <ch...@gmail.com>.
Apache commons dbcp [1] is more common IMO.

[1] http://commons.apache.org/proper/commons-dbcp/

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Wed, Jul 31, 2013 at 12:45 PM, Marco Crivellaro <ma...@gmail.com>wrote:

> I've found out you can use c3p0 library
> (http://www.mchange.com/projects/c3p0) so you can rely on connection
> pooling
> are not forced to write your own connection testing in the route.
>
> here is an example of the jdbc datasource bean:
>
>         <bean id="mysqlPooled"
> class="com.mchange.v2.c3p0.ComboPooledDataSource" >
>                 <property name="driverClass" value="com.mysql.jdbc.Driver"
> />
>                 <property name="jdbcUrl"
> value="jdbc:mysql://localhost:3306/test" />
>                 <property name="user" value="user" />
>                 <property name="password" value="pass" />
>                 <property name="minPoolSize" value="1" />
>                 <property name="maxPoolSize" value="5" />
>                 <property name="maxIdleTime" value="60" />
>                 <property name="maxStatements" value="0" />
>                 <property name="preferredTestQuery" value="SELECT 1;" />
>                 <property name="idleConnectionTestPeriod" value="30" />
>         </bean>
>
>
> just include c3p0 in your dependencies
>                 <dependency>
>                         <groupId>c3p0</groupId>
>                         <artifactId>c3p0</artifactId>
>                         <version>0.9.1.1</version>
>                 </dependency>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-sql-connection-test-required-tp5736549p5736555.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: camel-sql, connection test required?

Posted by Marco Crivellaro <ma...@gmail.com>.
I've found out you can use c3p0 library
(http://www.mchange.com/projects/c3p0) so you can rely on connection pooling
are not forced to write your own connection testing in the route.

here is an example of the jdbc datasource bean:

	<bean id="mysqlPooled" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test" />
		<property name="user" value="user" />
		<property name="password" value="pass" />
		<property name="minPoolSize" value="1" />
		<property name="maxPoolSize" value="5" />
		<property name="maxIdleTime" value="60" />
		<property name="maxStatements" value="0" />
		<property name="preferredTestQuery" value="SELECT 1;" />
		<property name="idleConnectionTestPeriod" value="30" />
	</bean>


just include c3p0 in your dependencies
		<dependency>
			<groupId>c3p0</groupId>
			<artifactId>c3p0</artifactId>
			<version>0.9.1.1</version>
		</dependency>



--
View this message in context: http://camel.465427.n5.nabble.com/camel-sql-connection-test-required-tp5736549p5736555.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-sql, connection test required?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah your connection pool may allow to setup keep alive queries or
test the connection before handing it over to the client.

There is no logic in camel-sql for validating the connection. You can
use Camels error handler to retry also which then would get a new
connection from the data source etc.

On Wed, Jul 31, 2013 at 10:18 AM, Marco Crivellaro
<ma...@gmail.com> wrote:
> Hi all,
> when using camel-sql should connection pooling and connection test be
> implemented?
> I am building a camel based application which will run as a daemon and might
> write the database once every few days. This means between writes the
> connection to the database (mysql) might timeout. Is camel testing
> connection before writing to the database or will it throw an exception in
> case the connection runs in timeout?
>
>
> Thanks,
> Marco
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-sql-connection-test-required-tp5736549.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen