camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aki Yoshida <elak...@gmail.com>
Subject Re: AHS-WS problem?
Date Thu, 20 Nov 2014 00:04:18 GMT
you don't have an input stream based message but you have a byte[]
message. the rest of the story stays the same.


2014-11-20 0:47 GMT+01:00 Aki Yoshida <elakito@gmail.com>:
> Hi,
> I can look at it tomorrow to confirm what I am saying below.
> A quick answer is that ahc-ws sends messages differently based on the
> java type of the message.
> In your case, you have an input stream based object when there is no
> string converter, In this case, the message is sent in a series of
> data fragments, where the last fragment is marked as "last".
>
> And I guess the camel-websocket can only  handle the plain string mode
> and ignores other types of data. I think camel-atmosphere-websocket
> should work with bytes or stream..
>
> regards, aki
>
>
> 2014-11-19 20:20 GMT+01:00 jogro <jonas.gronberg@gmail.com>:
>> 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.

Mime
View raw message