2012-07-15 14:12:03 +02:00
|
|
|
package docs.camel;
|
|
|
|
|
//#CustomRoute
|
|
|
|
|
import akka.actor.UntypedActor;
|
|
|
|
|
import akka.camel.CamelMessage;
|
|
|
|
|
import akka.japi.Function;
|
|
|
|
|
|
|
|
|
|
public class Responder extends UntypedActor{
|
|
|
|
|
|
|
|
|
|
public void onReceive(Object message) {
|
|
|
|
|
if (message instanceof CamelMessage) {
|
|
|
|
|
CamelMessage camelMessage = (CamelMessage) message;
|
2012-09-19 23:55:53 +02:00
|
|
|
getSender().tell(createResponse(camelMessage), getSelf());
|
2012-07-15 14:12:03 +02:00
|
|
|
} else
|
|
|
|
|
unhandled(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CamelMessage createResponse(CamelMessage msg) {
|
|
|
|
|
return msg.mapBody(new Function<String,String>() {
|
|
|
|
|
public String apply(String body) {
|
|
|
|
|
return String.format("received %s", body);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#CustomRoute
|