Package akka.camel

Examples of akka.camel.CamelMessage


import akka.dispatch.Mapper;

public class HttpTransformer extends UntypedActor {
  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      CamelMessage replacedMessage = camelMessage.mapBody(new Mapper<Object, String>() {
        @Override
        public String apply(Object body) {
          String text = new String((byte[]) body);
          return text.replaceAll("Akka ", "AKKA ");
        }
View Full Code Here


  // before producing messages to endpoints, producer actors can pre-process
  // them by overriding the onTransformOutgoingMessage method
  @Override
  public Object onTransformOutgoingMessage(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      Set<String> httpPath = new HashSet<String>();
      httpPath.add(Exchange.HTTP_PATH);
      return camelMessage.withHeaders(camelMessage.getHeaders(httpPath));
    } else
      return super.onTransformOutgoingMessage(message);
  }
View Full Code Here

    return "jetty:http://0.0.0.0:8877/camel/welcome";
  }

  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      // Forward a string representation of the message body to transformer
      String body = camelMessage.getBodyAs(String.class, getCamelContext());
      transformer.forward(camelMessage.withBody(body), getContext());
    } else
      unhandled(message);
  }
View Full Code Here

  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      // example: transform message body "foo" to "- foo -" and forward result
      // to producer
      CamelMessage camelMessage = (CamelMessage) message;
      CamelMessage transformedMessage = camelMessage.mapBody(new Mapper<String, String>() {
        @Override
        public String apply(String body) {
          return String.format("- %s -", body);
        }
      });
View Full Code Here

    return "quartz://example?cron=0/2+*+*+*+*+?";
  }

  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      System.out.println(String.format("==============> received %s ", camelMessage));
    } else
      unhandled(message);
  }
View Full Code Here

    return uri;
  }

  public void onReceive(Object message) throws Exception{
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      String body = camelMessage.getBodyAs(String.class, getCamelContext());
      throw new Exception(String.format("error: %s",body));
    } else
      unhandled(message);
  }
View Full Code Here

  }

  @Override
  public Object onTransformOutgoingMessage(Object message) {
    if(message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      return upperCase(camelMessage);
    } else {
      return message;
    }
  }
View Full Code Here

    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());
      getSender().tell(String.format("Received message: %s",body), getSelf());
    } else
      unhandled(message);
  }
View Full Code Here

public class Responder extends UntypedActor{

  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      getSender().tell(createResponse(camelMessage), getSelf());
    } else
      unhandled(message);
  }
View Full Code Here

    return "file:data/input/actor";
  }

  public void onReceive(Object message) {
    if (message instanceof CamelMessage) {
      CamelMessage camelMessage = (CamelMessage) message;
      String body = camelMessage.getBodyAs(String.class, getCamelContext());
      log.info("Received message: {}", body);
    } else
      unhandled(message);
  }
View Full Code Here

TOP

Related Classes of akka.camel.CamelMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.