Add type mapping to SimpleToAvroTransformer

* Fix setter names for expression Strings
This commit is contained in:
Gary Russell
2019-07-18 16:40:06 -04:00
committed by Artem Bilan
parent c109e1df34
commit 989d31716d
5 changed files with 167 additions and 18 deletions

View File

@@ -462,10 +462,13 @@ They are unsophisticated in that there is no schema registry; the transformers s
Messages sent to the `SimpleToAvroTransformer` must have a payload that implements `SpecificRecord`; the transformer can handle multiple types.
The `SimpleFromAvroTransformer` must be configured with a `SpecificRecord` class which is used as the default type to deserialize.
You can also specify a SpEL expression to determine the type to deserialize.
The default SpEL expression is `headers[avro_type]` (`AvroHeaders.TYPE`).
You can also specify a SpEL expression to determine the type to deserialize using the `setTypeExpression` method.
The default SpEL expression is `headers[avro_type]` (`AvroHeaders.TYPE`) which, by default, is populated by the `SimpleToAvroTransformer` with the fully qualified class name of the source class.
If the expression returns `null`, the `defaultType` is used.
The `SimpleToAvroTransformer` also has a `setTypeExpression` method.
This allows decoupling of the producer and consumer where the sender can set the header to some token representing the type and the consumer then maps that token to a type.
[[transformer-annotation]]
==== Configuring a Transformer with Annotations