Minor changes in akka-sample-camel
This commit is contained in:
parent
c9b3d3606b
commit
bd7bd160a0
2 changed files with 24 additions and 22 deletions
|
|
@ -117,14 +117,18 @@ class HttpConsumer(producer: ActorRef) extends Actor with Consumer {
|
|||
def endpointUri = "jetty:http://0.0.0.0:8875/"
|
||||
|
||||
protected def receive = {
|
||||
// only keep Exchange.HTTP_PATH message header (which needed by bridge endpoint)
|
||||
case msg: Message => producer forward msg.setHeaders(msg.headers(Set(Exchange.HTTP_PATH)))
|
||||
case msg => producer forward msg
|
||||
}
|
||||
}
|
||||
|
||||
class HttpProducer(transformer: ActorRef) extends Actor with Producer {
|
||||
def endpointUri = "jetty://http://akkasource.org/?bridgeEndpoint=true"
|
||||
|
||||
override protected def receiveBeforeProduce = {
|
||||
// only keep Exchange.HTTP_PATH message header (which needed by bridge endpoint)
|
||||
case msg: Message => msg.setHeaders(msg.headers(Set(Exchange.HTTP_PATH)))
|
||||
}
|
||||
|
||||
override protected def receiveAfterProduce = {
|
||||
// do not reply but forward result to transformer
|
||||
case msg => transformer forward msg
|
||||
|
|
|
|||
|
|
@ -16,16 +16,6 @@ import se.scalablesolutions.akka.config.ScalaConfig._
|
|||
*/
|
||||
class Boot {
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Create CamelContext with Spring-based registry and custom route builder
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
val context = new ClassPathXmlApplicationContext("/context-boot.xml", getClass)
|
||||
val registry = new ApplicationContextRegistry(context)
|
||||
|
||||
CamelContextManager.init(new DefaultCamelContext(registry))
|
||||
CamelContextManager.context.addRoutes(new CustomRouteBuilder)
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Basic example
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
@ -41,9 +31,17 @@ class Boot {
|
|||
// Supervise(actorOf[Consumer2], LifeCycle(Permanent)) :: Nil))
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Tranformer example
|
||||
// Custom Camel route example
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// Create CamelContext and a Spring-based registry
|
||||
val context = new ClassPathXmlApplicationContext("/context-boot.xml", getClass)
|
||||
val registry = new ApplicationContextRegistry(context)
|
||||
|
||||
// Use a custom Camel context and a custom touter builder
|
||||
CamelContextManager.init(new DefaultCamelContext(registry))
|
||||
CamelContextManager.context.addRoutes(new CustomRouteBuilder)
|
||||
|
||||
val producer = actorOf[Producer1]
|
||||
val mediator = actorOf(new Transformer(producer))
|
||||
val consumer = actorOf(new Consumer3(mediator))
|
||||
|
|
@ -52,12 +50,20 @@ class Boot {
|
|||
mediator.start
|
||||
consumer.start
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Non-blocking consumer-producer example (Akka homepage transformation)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
val httpTransformer = actorOf(new HttpTransformer).start
|
||||
val httpProducer = actorOf(new HttpProducer(httpTransformer)).start
|
||||
val httpConsumer = actorOf(new HttpConsumer(httpProducer)).start
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Publish subscribe examples
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Cometd example commented out because camel-cometd is broken in Camel 2.3
|
||||
// Cometd example commented out because camel-cometd is broken since Camel 2.3
|
||||
//
|
||||
|
||||
//val cometdUri = "cometd://localhost:8111/test/abc?baseResource=file:target"
|
||||
|
|
@ -79,14 +85,6 @@ class Boot {
|
|||
actorOf[Consumer4].start // POSTing "stop" to http://0.0.0.0:8877/camel/stop stops and unpublishes this actor
|
||||
actorOf[Consumer5].start // POSTing any msg to http://0.0.0.0:8877/camel/start starts and published Consumer4 again.
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Non-blocking consumer-producer example (Akka homepage transformation)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
val nbResponder = actorOf(new HttpTransformer).start
|
||||
val nbProducer = actorOf(new HttpProducer(nbResponder)).start
|
||||
val nbConsumer = actorOf(new HttpConsumer(nbProducer)).start
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Active object example
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue