Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Routers > Routers Using Annotations

Routers Using Annotations

We can also create Routers using Framework’s @Router annotation. All we have to do is decorate the appropriate method with this annotation on modified AnnotatedBigTradeRouter as shown below.

@Component
public class AnnotatedBigTradeRouter {
  @Router
  public String bigTrade(Message<Trade> message) {
    Trade t = message.getPayload();
    if (t.getQuantity() > 10000)
      return "big-trades-channel";
    return "trades-stdout";
  }
}

You have to wire the above bean using the ref attribute in the configuration file:

<context:component-scan 
  base-package="com.madhusudhan.jsi.flow.router" />

<int:router id="annonatedRouter" input-channel="in-channel"
  default-output-channel="no-matches-channel" 
  ref="annotatedBigTradeRouter">
</int:router>

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint