February 2015
Intermediate to advanced
198 pages
4h 17m
English
Spring's power comes from converting simple Java classes to specific components without extending or implementing external classes. To define routers, we can leverage the framework's @Router annotation. We can annotate any method with @Router, and can use its reference. Let's take an example where we want to route our feed based on the author:
@Component
public class AnnotatedFeedsAuthorRouter {
@Router
public String feedAuthor(Message<SoFeed > message) {
SoFeed sf = message.getPayload();
return sf.getAuthor() ;
}
}The return value is a string that is the author's name—a channel with the same name must be present. Alternatively, we can return MessageChannel or a list of MessageChannel references directly.
Read now
Unlock full access