Versions Compared

Key

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

...

Code Block
java
java
    @RecipientList 
    public String[] route(String body) { ... }
    
    @RecipientList 
    public List<String> route(String body) { ... }
    
    @RecipientList 
    public Endpoint route(String body) { ... }
    
    @RecipientList 
    public Endpoint[] route(String body) { ... }
    
    @RecipientList 
    public Collection<Endpoint> route(String body) { ... }
    
    @RecipientList 
    public URI route(String body) { ... }
    
    @RecipientList 
    public URI[] route(String body) { ... }
{code:java}



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.

h3. More Complex Example Using DSL

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

{code:java}

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.

More Complex Example Using DSL

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

Code Block
java
java
public class RouterBean2 {

    @RecipientList
    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").beanRef("myRouterBean", "route");
    }
}

...