Aggregator Serialization And Deserialization
By default, StackSaga uses Jackson ObjectMapper
for aggregator serialization and deserialization.
Therefore, It is possible to do default casting subject to ObjectMapper in StackSaga.
To do that you are able to use all the jackson-annotations that are provided by the Jackson ObjectMapper Library
.
It is recommended to use @JsonProperty annotation with a fixed-name for all the properties in your aggregator class.
It helps to keep the JSON properties safe from the Java codes in the event-store.The suggestion does not mean to keep the properties in SNAKE_CASE at all. Therefore, it is not recommended to use SNAKE_CASE configuration for all the properties in your aggregator class. Because it will be changed correspondingly to the property name every time you change the property name in the Java code. |
@SagaAggregator(
version = @SagaAggregatorVersion(major = 1, minor = 0, patch = 1),
idPrefix = "po",
name = "PlaceOrderAggregator",
sagaSerializable = PlaceOrderAggregatorSample.class,
mapper = PlaceOrderAggregatorJsonMapper.class
)
@Getter
@Setter
public class PlaceOrderAggregator extends Aggregator {
public PlaceOrderAggregator() {
super(PlaceOrderAggregator.class);
}
@JsonProperty("order_id")
private String orderId;
@JsonProperty("username")
private String username;
@JsonProperty("total")
private Double total;
@JsonProperty("is_active")
private int isActive;
@JsonProperty("item_details")
private List<ItemDetail> itemDetails = new ArrayList<>();
...
}