-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining datasource in groovy and using in XML routes #892
Comments
This is wrong, camel-k-runtime supports what Camel does but as the runtime is not based on spring-boot or blueprint, you cannot define beans in the XML.
This define a bean named def ds = new org.apache.commons.dbcp.BasicDataSource()
ds.url = 'jdbc:mysql://10.213.96.182/test'
ds.username = 'testuser'
ds.password = '******'
ds.driverClassName = 'com.mysql.jdbc.Driver'
context {
registry {
mysqlDataSource = ds
}
} Or context {
registry {
mysqlDataSource = [ url: '...', username: '....' ] as BasicDataSource
}
} If you use camel-k from master, then you can do something like: beans {
dataSource(org.apache.commons.dbcp2.BasicDataSource) {
driverClassName = "org.h2.Driver"
url = "jdbc:h2:mem:camel"
username = "sa"
password = ""
}
}
|
@lburgazzoli
and route as follows <?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<route streamCache="true">
<from uri="activemq:queue:test.queue" />
<log message="Received request to process" />
</route>
</routes> Camel K build doesn't complete and I see following message
Any examples on connecting to activeMQ from camel k projects? |
in pooledConnectionFactory, the connectionFactory is reference to another bean defined above that named activeMQConnectionFactory. I hope its the right way to provide reference to registrybeans |
I was referring http://www.javaoutofbounds.com/apache-camel-activemq-connection-pool-example/ to configure my beans |
Tried this too
|
@contactreji
|
@WillemJiang - I get following error while starting the app.
Route file
Groovy file
Camel command used
|
@contactreji Sorry, there is a typo on the 'userName' setting, the right one should be 'username'. I think we could update the DSL by showing the wrong setting on the component properties. |
Created an related issue apache/camel-k-runtime#137 in camel-k-runtime. |
Perfect. that worked! thanks @WillemJiang |
@contactreji can we close this one ? |
Closing this |
You can close this. thanks |
Hello !
Just need a quick help here. Bear with me as am not a groovy expert yet.
Since Camel k doesn't understand .. fragment, I tried adding a data-source bean via groovy script as follows
My route looks like
But looks like Camel-K doesn't detect this registry entry.
The text was updated successfully, but these errors were encountered: