-
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
Can camel-k accept camel context definition? #814
Comments
No, it understand route fragment only
On Fri, 12 Jul 2019 at 17:50, rejimathews ***@***.***> wrote:
Does camel K understand if I pass the camel context definitions? Like
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:Accounts.PurchaseOrders"/>
<to uri="seda:A"/>
</route>
<route>
<from uri="seda:A"/>
<to uri="activemq:UK.Accounts.Invoices"/>
</route>
</camelContext>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#814?email_source=notifications&email_token=AAOIJBJSIAIOK2BLYBLNKQTP7CR4HA5CNFSM4ICMOIZ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G65IBJQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOIJBKFA5RVFM26UVHLVXLP7CR4HANCNFSM4ICMOIZQ>
.
--
--
Luca Burgazzoli
|
From my understanding camel-k-runtime can load the camel route and camel dsl fragment out of box. But what if there are some customer bean definition need to be load or bean instance need to be created. How can we load these beans inside of camel-k-runtime? |
you need to use java/groovy and put your bean in the registry |
Is there a thought of making camel-k capable of accepting one global resource file which contains all configurations including routes, beans, conduit elements etc |
you can use a java/groovy, if you want to use XML you need to add also a java file that adds the beans to the registry. |
Do you have any examples for this? If so can you provide the link to the same? |
in the configure method just do something like |
Sounds great! Or rather, can i mix up routes , few from xml dsl and rest in groovy/java and have it all under single camelContext with common registry? |
Yes camel k has a single context
On Fri, 19 Jul 2019 at 22:20, rejimathews ***@***.***> wrote:
in the configure method just do something like getContext().getRegistry().bind(key,
val)
Sounds great!
I already have my project written as XML in route fragments. If I add a
groovy or java here (to bring in my datasource bean binding), if I pass
both xml and the java/groovy to "kamel run command", will it all get binded
under the same camelContext?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#814?email_source=notifications&email_token=AAOIJBK2KDR3R763TGIT5E3QAIOYNA5CNFSM4ICMOIZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2MVFDQ#issuecomment-513364622>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOIJBPBTGZQWKSX2MT5WATQAIOYNANCNFSM4ICMOIZQ>
.
--
--
Luca Burgazzoli
|
I just realized I was blocked while implementing this way. The same issue mentioned at this thread. https://developer.jboss.org/thread/235103 Looks like it returns a read only instance of the registry. I don't see a bind() method available to use in the instance. Is there another way to get modifiable instance of Registry? |
Yeah works only in camel 3 as it has a writable registry |
Thanks !! import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.CompositeRegistry;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.commons.dbcp.BasicDataSource;
public class EmbeddedRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
SimpleRegistry simpleRegistry = new SimpleRegistry();
BasicDataSource mysqlDataSource = new BasicDataSource();
mysqlDataSource.setUrl("jdbc:mysql://10.213.96.182/schemaname");
mysqlDataSource.setUsername("********");
mysqlDataSource.setPassword("***********");
mysqlDataSource.setDriverClassName("com.mysql.jdbc.Driver");
CamelContext camelContext = getContext();
CompositeRegistry compositeRegistry = getCompositeRegistry();
compositeRegistry.addRegistry(getContext().getRegistry());
compositeRegistry.addRegistry(simpleRegistry);
((DefaultCamelContext)camelContext).setRegistry(compositeRegistry);
simpleRegistry.put("mysqlDataSource", mysqlDataSource);
}
private CompositeRegistry getCompositeRegistry() {
CompositeRegistry registry = new CompositeRegistry();
return registry;
}
} |
Notice that also in the examples came-k folder there is an example of using @BindToRegistry in conjunction of using multiple files for deploying one integration. I want also to mention I wan't able to use "packages" for language "java" that will be helpful to have better organization of code supporting logical needed for each integration. I mean, what I'm trying to do is separe the logic from the route itself, so I've created two different java files, one containing only the route, and other implementing the utils (for example), the first one I want to place it in a "package org.something.integrations.route" and the other in a "package org.something.integrations.utils" if I did it in this way and execute this command: The content of java files are: package org.something.integrations.route; import org.apache.camel.builder.RouteBuilder; public class ExampleRoute extends RouteBuilder { @OverRide
} ExampleUtils.java package org.something.integrations.utils; import org.apache.camel.builder.RouteBuilder; public class ExampleUtils extends RouteBuilder {
} Done using:
|
can you rephrase it ? I don't get what you are trying to describe |
Does camel K understand if I pass the camel context definitions? Like
The text was updated successfully, but these errors were encountered: