You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jgoggins <jo...@hotmail.com> on 2016/01/31 01:22:30 UTC

Shared Camel Context.

Can Camel Context be shared between an Akka Actor application and a Spring
Boot jar file it is consuming. I want to route endpoints in the jar to the
actor. Although many examples and readings seem to state this as a trival
task, the execution is not the case. I see 2 camel context's started, one in
Spring Boot when it is instantiated within the Scala application using
"SpringApplication.run(classOf[Application])" and one in the Akka
application on calling "CamelExtension(actorSystem).context". I have spent
some time on this. Recently I noted in a support forum this was not possible
and using direct-vm would be a solution. With limited information available,
could someone here guide me ? 
         



--
View this message in context: http://camel.465427.n5.nabble.com/Shared-Camel-Context-tp5777066.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Shared Camel Context.

Posted by jgoggins <jo...@hotmail.com>.
It seems this was incorrect; 
I removed @Endpoint public class HeartbeatEndpoint. 

My router is setup as 

@Component 
    public class MyRouter extends SpringRouteBuilder { 
        @Override 
        public void configure() throws Exception { 
            
from("spring-ws:rootqname:{http://myevent/Heartbeat}Heartbeat?endpointMapping=#endpointMapping") 
             .log("************* output from java ***************");
    } 

Because this is representing a service already defined, it is SOAP12. 

I already have the bean configured when the @Endpoint HeartbeatEndpoint was
working 

    @Bean(name = "soap12")
    public SaajSoapMessageFactory soap12MessageFactory() throws
SOAPException {
        MessageFactory messageFactory =
MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        SaajSoapMessageFactory factory = new
SaajSoapMessageFactory(messageFactory); 
        return factory;
    }

but the camel route builder does not see it. 
    Error is SoapMessageDispatcher  : Could not handle mustUnderstand
headers:    
{http://www.w3.org/2005/08/addressing}Action,{http://www.w3.org/2005/08/addressing}To.    
Returning fault


I attempted to use the MessageFactory as
"?endpointMapping=#endpointMapping&messageFactory=#soap12MessageFactory"

but received the error  
    llegalArgumentException: Could not find a suitable setter for property:
messageFactory as there isn't a setter method

Using here as a reference
http://camel.apache.org/spring-web-services.html







--
View this message in context: http://camel.465427.n5.nabble.com/Shared-Camel-Context-tp5777066p5777156.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Shared Camel Context.

Posted by jgoggins <jo...@hotmail.com>.
Hi Matt, 

Still unable to make progress here. I have a simple SOAP 12 endpoint
defined, and this is working if I send a request. 

        @Endpoint 
        public class HeartbeatEndpoint {  
                @Action("http://myevent/Heartbeat") 
                @ResponsePayload 
                public HeartbeatResponse Heartbeat(@RequestPayload Heartbeat
arg) { 
                        HeartbeatResponse response = new
HeartbeatResponse(); 
                        response.setHeartbeatResult(5); 
                        System.out.println("HEART BEAT"); 
                        return response; 
                } 
        } 

I setup a route earlier

    @Component
    public class MyRouter extends SpringRouteBuilder {
        @Override
        public void configure() throws Exception {
            
from("spring-ws:uri:http://myevent/Heartbeat?endpointMapping=#endpointMapping")
             .to("log:output?showAll=true")
             .to("direct-vm:processOrder");
    }

I tried all different from patterns but get unresolved endpoint exceptions. 
When I post a message to the endpoint I use "http://localhost:8080/myevent"
but this is also not working. If I use
from("spring-ws:http://localhost:8080/myevent"), this will start but when I
post a message, it arrives at the endpoint and is not processed by the camel
endpoint. 

This is how I setup the route

    @Bean
    public CamelContext camelContext() throws Exception {
        CamelContext camelContext = new
SpringCamelContext(applicationContext); 
        camelContext.addRoutes(new CTIPsRouter()); 
        return camelContext;
    }




--
View this message in context: http://camel.465427.n5.nabble.com/Shared-Camel-Context-tp5777066p5777096.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Shared Camel Context.

Posted by jgoggins <jo...@hotmail.com>.
Cheers Matt 



--
View this message in context: http://camel.465427.n5.nabble.com/Shared-Camel-Context-tp5777066p5777084.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Shared Camel Context.

Posted by Matt Sicker <bo...@gmail.com>.
Using direct-vm is for when you have multiple CamelContexts running. I use
it in OSGi, seems like it works just the same anywhere there is more than
one CamelContext or possibly even ClassLoader.

On 30 January 2016 at 18:22, jgoggins <jo...@hotmail.com> wrote:

> Can Camel Context be shared between an Akka Actor application and a Spring
> Boot jar file it is consuming. I want to route endpoints in the jar to the
> actor. Although many examples and readings seem to state this as a trival
> task, the execution is not the case. I see 2 camel context's started, one
> in
> Spring Boot when it is instantiated within the Scala application using
> "SpringApplication.run(classOf[Application])" and one in the Akka
> application on calling "CamelExtension(actorSystem).context". I have spent
> some time on this. Recently I noted in a support forum this was not
> possible
> and using direct-vm would be a solution. With limited information
> available,
> could someone here guide me ?
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Shared-Camel-Context-tp5777066.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>