Annotation Interface RoutingKey
This annotation can be used as a field, method or type annotation in a payload class. If placed on a method, that
method must contain no parameters. If it is on a field or getter method it uses the property to obtain the routing
key. The value of the property will be converted to a string via the value's toString()
method.
If the annotation is used at the class level of the payload class, a property name should be specified using
value()
. That property will first be looked up inside the message's
Metadata
. If it is not found there, the property will be looked for inside the
payload. In that case, the property name may also contain one or more slashes ('/') if the property is hiding inside
an embedded field.
Finally, it is also possible to place this annotation on a handler method. In that case, the property name specified
by value()
of the payload (metadata or payload property) will be used to compute the routing key before
handling. This effectively overrides any routing key computed upon publication of the message. Important note:
if the annotation is on a handler method, make sure the consumer configuration has ignoreSegment =
true
; otherwise messages may be missed by the consumer.
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueReturns the metadata key or property name to use to look up the routing key. If left empty, the annotated field or method will be used to determine the routing key.- Default:
""
-