Hello everybody,
I just posted a problem I am struggling with on stackoverflow
http://stackoverflow.com/questions/28982333/akka-camel-websocket-client-producer.
I haven't got too many views there and no answer so far, so decided to post
it over here to people who use Akka the most; maybe someone will be able to
help me out.
I will copy my stackoverflow post here.
I am trying to communicate with a websocket server using Apache Camel
AHC-Websocket Component with Akka Camel in Java. In this case, websocket
endpoint is goint to be a well known websocket public service
https://www.websocket.org/echo.html.
Using:
- JDK *8.x*
- Akka Java API with Akka Camel, Akka Actor and Akka SLF4J *2.3.9*
- Apache Camel with AHC WS Component *2.14.1*
I followed Akka Camel tutorial for Java located over here
http://doc.akka.io/docs/akka/2.1.4/java/camel.html.
Short description: Every response received by UntypedProducerActor when I
make a request returns CamelMessage with body field as null. But when I
make request via ProducerTemplate I receive correct response.
Long description: I am getting strange behaviour from Akka Camel when I
make a request and expect a response from the websocket endpoint. When I
make a request to the endpoint via defined ActorRef, for example like so:
ActorRef wsProducer =
getContext().actorOf(SimpleProducer.props(ahc-ws:echo.websocket.org));
final Timeout timeout = new Timeout(3, TimeUnit.MINUTES);final FutureObject
future = Patterns.ask(wsProducer, Please, respond!, timeout);final Object
result = Await.result(future, timeout.duration());
I clearly see in the logs that Apache Camel websocket endpoint received a
response:
DEBUG o.a.c.component.ahc.ws.WsEndpoint - received message -- Please,
respond!
But the result object will be a CamelMessage with body field always set to
null. The same CamelMessage present in public Object
onTransformResponse(Object message) method of my SimpleProducer.
However, when I make request via ProducerTemplate like this:
final Camel camel = CamelExtension.get(getContext().system());final
CamelContext context = camel.context();final ProducerTemplate template =
camel.template();
Object result = template.requestBody(ahc-ws:echo.websocket.org, Alpha is
there!);
It works and result will contain correct response body: Alpha is there!.
My SimpleProducer is pretty much the same as in tutorial:
public class SimpleProducer extends UntypedProducerActor {
private final LoggingAdapter LOG = Logging.getLogger(getContext().system(),
this);
private final String mEndpointUri;
public SimpleProducer(final String serverUrl) {
mEndpointUri = serverUrl;
}
@Override
public String getEndpointUri() {
return mEndpointUri;
}
@Override
public Object onTransformResponse(Object message) {
return super.onTransformOutgoingMessage(message);
}
@Override
public boolean isOneway() {
return false;
}
public static Props props(final String endpointUri) {
return Props.create(new CreatorSimpleProducer() {
private static final long serialVersionUID = 1L;
@Override
public SimpleProducer create() throws Exception {
return new SimpleProducer(endpointUri);
}
});
}}
Maybe somebody had the same issue and can help me out?
--
Read the docs: http://akka.io/docs/
Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups Akka
User List group.
To unsubscribe from this group and stop receiving emails from it, send an email
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.