Hi,

I wanted to try out the new AHS-WS and Websocket components together with
Spring Boot so I set up
two maven projects based on
 
        Spring Roo 1.1.9.RELEASE
        Apache Camel 2.14.0.
        Java 1.8_05 (MacOS X) 

One client project using the following route configuration:

        from("direct:echo")
                        .autoStartup(true)
                        .marshal().base64()
                        .convertBodyTo(String.class)
                        .to("ahc-ws://localhost:9292/echo?sync=true");

                from("ahc-ws://localhost:9292/echo?sync=true")
                        .log("Got ${body}");
                        
One server project using the following route configuration:

        from("websocket://echo")
                .unmarshal().base64()
            .log(">>> Message received from WebSocket Client : ${body}")
            .transform().simple("${in.body}")
            .to("websocket://echo");

These configurations actually work fine. Invoking

producerTemplate.requestBody("direct:echo", "Jonas")

generates a log like this.

2014-11-19 19:43:10.855 DEBUG 8577 --- [lication Thread]
o.a.camel.component.ahc.ws.WsProducer    : Sending out Sm9uYXM=

2014-11-19 19:43:11.190  INFO 8577 --- [w I/O worker #1]
o.a.camel.component.ahc.ws.WsEndpoint    : websocket opened
2014-11-19 19:43:11.309  INFO 8577 --- [w I/O worker #1]
o.a.camel.component.ahc.ws.WsEndpoint    : received message --> Hello Jonas!
2014-11-19 19:43:11.326  INFO 8577 --- [w I/O worker #1] route2                 
                 
: Got Hello Jonas!

But if I remove the call to convertBodyTo method in the client
configuration, the invocation above never gets a response from the server.
The log below shows two invocations:

2014-11-19 19:48:33.634 DEBUG 8592 --- [lication Thread]
o.a.camel.component.ahc.ws.WsProducer    : Sending out [83, 109, 57, 117,
89, 88, 77, 61, 13, 10]
2014-11-19 19:48:33.822  INFO 8592 --- [w I/O worker #1]
o.a.camel.component.ahc.ws.WsEndpoint    : websocket opened
2014-11-19 19:48:37.740 DEBUG 8592 --- [lication Thread]
o.a.camel.component.ahc.ws.WsProducer    : Sending out [83, 109, 57, 117,
89, 88, 77, 61, 13, 10]

What do you think? Is this a bug or is some configuration missing?

My client application config looks like this:

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
        @Bean
        public ProducerTemplate producerTemplate(SpringCamelContext context) {
                return context.createProducerTemplate();
        }
        @Bean
        public SpringCamelContext camelContext(ApplicationContext
applicationContext)
                        throws Exception {
                SpringCamelContext camelContext = new SpringCamelContext(
                                applicationContext);
                camelContext.addRoutes(routeBuilder());
                return camelContext;
        }
        @Bean
        public RouteBuilder routeBuilder() {
                return new RouteBuilder() {
                        @Override
                        public void configure() throws Exception {
                                from("direct:echo")
                                        .autoStartup(true)
                                        .marshal().base64()
                                        .convertBodyTo(String.class)
                                        
.to("ahc-ws://localhost:9292/echo?sync=true");

                                from("ahc-ws://localhost:9292/echo?sync=true")
                                        .log("Got ${body}");
                        }
                };
        }
}

My server application config looks like this:

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
        @Bean
        public SpringCamelContext camelContext(ApplicationContext
applicationContext)
                        throws Exception {
                SpringCamelContext camelContext = new SpringCamelContext(
                                applicationContext);
                camelContext.addRoutes(routeBuilder());
                return camelContext;
        }
        @Bean
        public RouteBuilder routeBuilder() {
                return new RouteBuilder() {
                    @Override
                    public void configure() throws Exception {
                        from("websocket://echo")
                                .unmarshal().base64()
                            .transform().simple("Hello ${body}!")
                            .to("websocket://echo");
                    }
                };
        }

        public static void main(String[] args) {
                SpringApplication.run(Application.class, args);
        }
}










--
View this message in context: 
http://camel.465427.n5.nabble.com/AHS-WS-problem-tp5759334.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to