You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kumar5 <de...@gmail.com> on 2016/04/08 16:42:04 UTC
camel-2.16.2 spring and java DSL register
i am using camel-2.16.2 , spring boot and java DSL. As document says if
spring then use ApplicationContextRegistry but ApplicationContextRegistry
doesn't have any method to added registry.
i want to register bean in Java DSL. please any one help me on this.
@Bean
RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() {
CamelContext context = getContext();
PropertyPlaceholderDelegateRegistry registry =
(PropertyPlaceholderDelegateRegistry)context.getRegistry();
ApplicationContextRegistry aRegistry =
(ApplicationContextRegistry) registry.getRegistry();
--
View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-2.16.2 spring and java DSL register
Posted by kumar5 <de...@gmail.com>.
thanks it worked.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772p5780844.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-2.16.2 spring and java DSL register
Posted by Claus Ibsen <cl...@gmail.com>.
Try add methods like this in the route builder class
@Bean("fallback")
Endpoint fallbackEndpoint(CamelContext context) {
return context.getEndpoint("xxxx");
}
On Fri, Apr 8, 2016 at 6:08 PM, kumar5 <de...@gmail.com> wrote:
> thanks
> i am using camel-hystrix 2.18.0 code which is not release at but i
> requirement to use it.
> i was using as given in test case but i am getting error :Caused by:
> java.lang.IllegalStateException: Another strategy was already registered.
>
> @Bean
> RouteBuilder createRouteBuilder() {
> return new RouteBuilder() {
>
> @Override
> public void configure() {
> CamelContext context = getContext();
> SimpleRegistry registry = new SimpleRegistry();
>
> context = new DefaultCamelContext(registry);
> registry.put("run", context.getEndpoint("direct:run"));
> registry.put("fallback",
> context.getEndpoint("direct:fallback"));
> registry.put("headerExpression",
> ExpressionBuilder.headerExpression("key"));
> from("direct:fallback")
> .log("======================== fallback")
> .to("mock:error");
>
> from("direct:run")
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws
> Exception {
> Thread.sleep(500); //a slow operation
> }
> })
> .log("======================== this is run")
> .to("mock:result");
>
> from("direct:MainRouteStart")
>
> .to("hystrix:testKey?runEndpointId=direct:run&fallbackEndpointId=direct:fallback&executionTimeoutInMilliseconds=100");
> }
> };
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772p5780782.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: camel-2.16.2 spring and java DSL register
Posted by kumar5 <de...@gmail.com>.
i got resolved "Another strategy was already registered". but i dont know
how to register enpoints in camel registry so hystrix can call.
Please any one help me how to registry endpoint in java dsl spring boot.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772p5780793.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-2.16.2 spring and java DSL register
Posted by kumar5 <de...@gmail.com>.
thanks
i am using camel-hystrix 2.18.0 code which is not release at but i
requirement to use it.
i was using as given in test case but i am getting error :Caused by:
java.lang.IllegalStateException: Another strategy was already registered.
@Bean
RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() {
CamelContext context = getContext();
SimpleRegistry registry = new SimpleRegistry();
context = new DefaultCamelContext(registry);
registry.put("run", context.getEndpoint("direct:run"));
registry.put("fallback",
context.getEndpoint("direct:fallback"));
registry.put("headerExpression",
ExpressionBuilder.headerExpression("key"));
from("direct:fallback")
.log("======================== fallback")
.to("mock:error");
from("direct:run")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
Thread.sleep(500); //a slow operation
}
})
.log("======================== this is run")
.to("mock:result");
from("direct:MainRouteStart")
.to("hystrix:testKey?runEndpointId=direct:run&fallbackEndpointId=direct:fallback&executionTimeoutInMilliseconds=100");
}
};
}
--
View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772p5780782.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-2.16.2 spring and java DSL register
Posted by kumar5 <de...@gmail.com>.
i am using camel 2.16.2 and java dsl , spring boot.
i am using camel-hystrix 2.18.0 code which is not release at but i
requirement to use hystrix. endpoint is register using SimpleRegistry so,
hystrix can get as below link code but spring boot will get
ApplicationContextRegistry. Please let me how register endpoint in
ApplicationContextRegistry
https://github.com/apache/camel/blob/master/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/HystrixComponentTimeOutTest.java
--
View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772p5780795.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-2.16.2 spring and java DSL register
Posted by Claus Ibsen <cl...@gmail.com>.
Register the bean using the spring-boot way using @Bean or @Component etc
On Fri, Apr 8, 2016 at 4:42 PM, kumar5 <de...@gmail.com> wrote:
> i am using camel-2.16.2 , spring boot and java DSL. As document says if
> spring then use ApplicationContextRegistry but ApplicationContextRegistry
> doesn't have any method to added registry.
> i want to register bean in Java DSL. please any one help me on this.
>
> @Bean
> RouteBuilder createRouteBuilder() {
> return new RouteBuilder() {
> @Override
> public void configure() {
> CamelContext context = getContext();
> PropertyPlaceholderDelegateRegistry registry =
> (PropertyPlaceholderDelegateRegistry)context.getRegistry();
> ApplicationContextRegistry aRegistry =
> (ApplicationContextRegistry) registry.getRegistry();
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-2-16-2-spring-and-java-DSL-register-tp5780772.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