Package com.yahoo.messagebus.routing
Interface RoutingPolicy
- All Known Implementing Classes:
CustomPolicy
public interface RoutingPolicy
Decides how to choose between candidate recipients of a hop template point.
The routing policy will be given an address and a set of recipients matching this address. It is responsible for
choosing one of the given recipients each time select(com.yahoo.messagebus.routing.RoutingContext)
is called. The routing policy chooses which recipient
to return each time at its sole discretion, using information in the RoutingContext argument to choose or not as required
to implement the policy.
Example:
- The given address is
a/b/?
- The given recipients are
a/b/c, a/b/d and a/b/e
- one of these three must be returned on every call tochoose
This class is pluggable per template point in the address of a hop.
- Author:
- bratseth, Simon Thoresen Hult
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroys this factory and frees up any resources it has held.void
merge
(RoutingContext context) This function is called when all replies have arrived for some message.void
select
(RoutingContext context) This function must choose a set of services that is to receive the given message from a list of possible recipients.
-
Method Details
-
select
This function must choose a set of services that is to receive the given message from a list of possible recipients. This is done by adding child routing contexts to the argument object. These children can then be iterated and manipulated even before selection pass is concluded.- Parameters:
context
- the complete context for the invocation of this policy. Contains all available data.
-
merge
This function is called when all replies have arrived for some message. The implementation is responsible for merging multiple replies into a single sensible reply. The replies is contained in the child context objects of the argument context, and then response must be set in that context.- Parameters:
context
- the complete context for the invocation of this policy. Contains all available data.
-
destroy
void destroy()Destroys this factory and frees up any resources it has held. Making further calls on a destroyed factory causes a runtime exception.
-