Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
    ">

  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"/>

  <bean id="myRecipientListmyRoutingSlip" class="com.acme.foo.RouterBean"/>

</beans>

...

Code Block
java
java
@RoutingSlip
public String[] route(String body) { ... }

@RoutingSlip 
public List<String> route(String body) { ... }

@RoutingSlip 
public Endpoint route(String body) { ... }

@RoutingSlip 
public Endpoint[] route(String body) { ... }

@RoutingSlip 
public Collection<Endpoint> route(String body) { ... }

@RoutingSlip 
public URI route(String body) { ... }

@RecipientList @RoutingSlip
public URI[] route(String body) { ... }

Then for each endpoint or URI the message is forwarded a separate copy to that endpointrouted accordingly to the returned slip. See details at the Routing Slip EIP.

You can then use whatever Java code you wish to figure out what endpoints to route to; for example you can use the Bean Binding annotations to inject parts of the message body or headers or use Expression values on the message.

...

In this example we will use more complex Bean Binding, plus we will use a separate route to invoke the Recipient List Routing Slip

Code Block
java
java
public class RouterBean2 {

    @RoutingSlip
    public String route(@Header("customerID") String custID String body) {
    	if (custID == null)  return null;
        return "activemq:Customers.Orders." + custID;
    }
}

public class MyRouteBuilder extends RouteBuilder {
    protected void configure() {
        from("activemq:Orders.Incoming").routingSlip(bean("myRouterBean", "route"));
    }
}

...