2012-07-15 14:12:03 +02:00
|
|
|
package docs.camel;
|
|
|
|
|
//#Consumer4
|
|
|
|
|
import akka.camel.CamelMessage;
|
|
|
|
|
import akka.camel.javaapi.UntypedConsumerActor;
|
2012-10-15 16:18:52 +02:00
|
|
|
import scala.concurrent.duration.Duration;
|
|
|
|
|
import scala.concurrent.duration.FiniteDuration;
|
2012-07-15 14:12:03 +02:00
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
public class Consumer4 extends UntypedConsumerActor {
|
2012-10-01 20:35:19 +02:00
|
|
|
private final static FiniteDuration timeout =
|
|
|
|
|
Duration.create(500, TimeUnit.MILLISECONDS);
|
2012-07-15 14:12:03 +02:00
|
|
|
|
|
|
|
|
@Override
|
2012-09-03 12:08:46 +02:00
|
|
|
public FiniteDuration replyTimeout() {
|
2012-07-15 14:12:03 +02:00
|
|
|
return timeout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getEndpointUri() {
|
|
|
|
|
return "jetty:http://localhost:8877/camel/default";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onReceive(Object message) {
|
|
|
|
|
if (message instanceof CamelMessage) {
|
|
|
|
|
CamelMessage camelMessage = (CamelMessage) message;
|
|
|
|
|
String body = camelMessage.getBodyAs(String.class, getCamelContext());
|
improve AbstractActor, #21717
* Receive class that wraps PartialFunction, to avoid
scary scala types
* move AbstractActorContext to AbstractActor.ActorContext
* converting docs, many, many UntypedActor
* removing UntypedActor docs
* add unit test for ReceiveBuilder
* MiMa filters
* consistent use of getContext(), self(), sender()
* rename cross references
* migration guide
* skip samples for now
* improve match type safetyi, add matchUnchecked
* the `? extends P` caused code like this to compile:
`match(String.class, (Integer i) -> {})`
* added matchUnchecked, since it can still be useful (um, convenient)
to be able to do:
`matchUnchecked(List.class, (List<String> list) -> {})`
* eleminate some scala.Option
* preRestart
* findChild
* ActorIdentity.getActorRef
2016-12-13 10:59:29 +01:00
|
|
|
sender().tell(String.format("Hello %s",body), self());
|
2012-07-15 14:12:03 +02:00
|
|
|
} else
|
|
|
|
|
unhandled(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//#Consumer4
|