You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Launcelot <dr...@standard.com> on 2016/12/19 18:19:06 UTC
sql component using spring-boot datasource
This could be a rookie mistake, if so apologies in advance
My router code :
@SpringBootApplication
public class MySpringBootRouter extends RouteBuilder {
@Autowired
DataSource dataSource;
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public void configure() {
DataFormat mySyslog = new SyslogDataFormat().getDataFormat();
from("sql:select * from o365investigations.auditaad where
status=0").routeId("aadroute")
.onException(java.lang.Exception.class).useOriginalMessage().handled(true)
.to("sql:update o365investigations.auditaad set Status=2 where id =
:#ID?dataSource=#dataSource")
.log("Exception in auditaad ").end().transacted()
.to("sql:update o365investigations.auditaad set status=1 where id =
:#ID?dataSource=#dataSource")
.to("direct:debug").bean("com.standard.camel.converter.AuditToSyslogBean").marshal(mySyslog)
.to("mina2:udp://localhost:514?sync=false");
from("direct:debug").log("$body");
}
}
My application.yml :
spring.main.sources: deleteme.MySpringBootRouter
spring.datasource.url: jdbc:mysql://localhost:3306/o365investigations
spring.datasource.username: <snip>
spring.datasource.password: <snip>
spring.datasource.driver-class-name: com.mysql.jdbc.Driver
On mvn spring-boot:run I get
Failed to resolve endpoint:
sql://select%20*%20from%20o365investigations.auditaad%20where%20status=0 due
to: DataSource must be configured -> [Help 1]
I initially had dataSource=dataSource in the url but changed it to
#dataSource based on a post i saw trawling for a solution by Mr Ibsen.
Either way gives me the same error.
Please help,
Thanks
--
View this message in context: http://camel.465427.n5.nabble.com/sql-component-using-spring-boot-datasource-tp5791719.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: sql component using spring-boot datasource
Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Hi,
I think this is already possible. We may dig into why this is not working for you, though you can find a working example here:
The data source configuration:
https://github.com/fabric8-quickstarts/spring-boot-camel-rest-sql/blob/3fdcb17ce52d3f42f63dc38e6d73cf97deafefb2/src/main/resources/application.yml#L26-L29
And the use in the Camel DSL:
https://github.com/fabric8-quickstarts/spring-boot-camel-rest-sql/blob/3fdcb17ce52d3f42f63dc38e6d73cf97deafefb2/src/main/java/io/fabric8/quickstarts/camel/Application.java#L63
Antonin
> On 19 Dec 2016, at 19:25, Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi
>
> Yeah it would be nicer if we can make it use the spring boot data
> source OOTB, you setup in the application.properties file.
>
> I have logged a ticket
> https://issues.apache.org/jira/browse/CAMEL-10618
>
>
>
> On Mon, Dec 19, 2016 at 7:19 PM, Launcelot <dr...@standard.com> wrote:
>> This could be a rookie mistake, if so apologies in advance
>> My router code :
>> @SpringBootApplication
>> public class MySpringBootRouter extends RouteBuilder {
>>
>> @Autowired
>> DataSource dataSource;
>>
>> public DataSource getDataSource() {
>> return dataSource;
>> }
>>
>> public void setDataSource(DataSource dataSource) {
>> this.dataSource = dataSource;
>> }
>>
>> @Override
>> public void configure() {
>>
>> DataFormat mySyslog = new SyslogDataFormat().getDataFormat();
>>
>> from("sql:select * from o365investigations.auditaad where
>> status=0").routeId("aadroute")
>>
>> .onException(java.lang.Exception.class).useOriginalMessage().handled(true)
>> .to("sql:update o365investigations.auditaad set Status=2 where id =
>> :#ID?dataSource=#dataSource")
>> .log("Exception in auditaad ").end().transacted()
>> .to("sql:update o365investigations.auditaad set status=1 where id =
>> :#ID?dataSource=#dataSource")
>>
>> .to("direct:debug").bean("com.standard.camel.converter.AuditToSyslogBean").marshal(mySyslog)
>> .to("mina2:udp://localhost:514?sync=false");
>>
>> from("direct:debug").log("$body");
>>
>> }
>>
>> }
>>
>> My application.yml :
>>
>> spring.main.sources: deleteme.MySpringBootRouter
>> spring.datasource.url: jdbc:mysql://localhost:3306/o365investigations
>>
>> spring.datasource.username: <snip>
>>
>> spring.datasource.password: <snip>
>>
>> spring.datasource.driver-class-name: com.mysql.jdbc.Driver
>>
>> On mvn spring-boot:run I get
>> Failed to resolve endpoint:
>> sql://select%20*%20from%20o365investigations.auditaad%20where%20status=0 due
>> to: DataSource must be configured -> [Help 1]
>>
>> I initially had dataSource=dataSource in the url but changed it to
>> #dataSource based on a post i saw trawling for a solution by Mr Ibsen.
>> Either way gives me the same error.
>>
>> Please help,
>>
>> Thanks
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/sql-component-using-spring-boot-datasource-tp5791719.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
Re: sql component using spring-boot datasource
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah it would be nicer if we can make it use the spring boot data
source OOTB, you setup in the application.properties file.
I have logged a ticket
https://issues.apache.org/jira/browse/CAMEL-10618
On Mon, Dec 19, 2016 at 7:19 PM, Launcelot <dr...@standard.com> wrote:
> This could be a rookie mistake, if so apologies in advance
> My router code :
> @SpringBootApplication
> public class MySpringBootRouter extends RouteBuilder {
>
> @Autowired
> DataSource dataSource;
>
> public DataSource getDataSource() {
> return dataSource;
> }
>
> public void setDataSource(DataSource dataSource) {
> this.dataSource = dataSource;
> }
>
> @Override
> public void configure() {
>
> DataFormat mySyslog = new SyslogDataFormat().getDataFormat();
>
> from("sql:select * from o365investigations.auditaad where
> status=0").routeId("aadroute")
>
> .onException(java.lang.Exception.class).useOriginalMessage().handled(true)
> .to("sql:update o365investigations.auditaad set Status=2 where id =
> :#ID?dataSource=#dataSource")
> .log("Exception in auditaad ").end().transacted()
> .to("sql:update o365investigations.auditaad set status=1 where id =
> :#ID?dataSource=#dataSource")
>
> .to("direct:debug").bean("com.standard.camel.converter.AuditToSyslogBean").marshal(mySyslog)
> .to("mina2:udp://localhost:514?sync=false");
>
> from("direct:debug").log("$body");
>
> }
>
> }
>
> My application.yml :
>
> spring.main.sources: deleteme.MySpringBootRouter
> spring.datasource.url: jdbc:mysql://localhost:3306/o365investigations
>
> spring.datasource.username: <snip>
>
> spring.datasource.password: <snip>
>
> spring.datasource.driver-class-name: com.mysql.jdbc.Driver
>
> On mvn spring-boot:run I get
> Failed to resolve endpoint:
> sql://select%20*%20from%20o365investigations.auditaad%20where%20status=0 due
> to: DataSource must be configured -> [Help 1]
>
> I initially had dataSource=dataSource in the url but changed it to
> #dataSource based on a post i saw trawling for a solution by Mr Ibsen.
> Either way gives me the same error.
>
> Please help,
>
> Thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/sql-component-using-spring-boot-datasource-tp5791719.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2