0

Switchyard is new thing for me, and i'm quite lost in where to look. What i have i two services connected by ESB. From sender i send simple class with data. Based on type of class i want receiver side decide what to do. So type of class will be action, and data in that class will be used as values for that action.

For example if i want to create new Customer i send to bus something like this:

class CreateCustomerMessage{
  public String fName;
  public String lName;
  public Int age;
}

receiver gets message, sees that he has to create customer and routes this message to

class CustomerOperationsBean{
  public Long createCustomer(CreateCustomerMessage message){...}
}

And creates this customer. Can please someone show me how to do that?

partTimeNinja
  • 191
  • 1
  • 12

1 Answers1

0

So, here what i've found. If you have a CamelService ( i use java routing config ) you can match against incoming message class using construction similar to this :

public void configure() {
 from("switchyard://QueueConsumerService")
        .choice()
                .when(body(InventoryRequest.class))
                    .log("Received Inventory message : ${body}")
                    .to("some_endpoint")
                .when(body(AuditRequest.class))
                    .log("Audit request : ${body}");
                    .to("some_other_endpoint")
}

and that's it. some_endpoint and some_other_endpoint here can be any endpoint, java class or another Camel router. gl hf.

partTimeNinja
  • 191
  • 1
  • 12