Extension for transaction-outbox-core which uses Jackson for serialisation.
If you are confident in trusting your database, then this serializer has a number of advantages: it is as
configurable as whatever Jackson's ObjectMapper
can handle, and explicitly handles n-depth polymorphic trees. This
largely means that you can throw pretty much anything at it and it will "just work".
However, if there is any risk that you might not trust the source of the serialized Invocation
,
do not use this. This serializer is vulnerable to
deserialization of untrusted data,
which is why it is not included in the core library.
<dependency>
<groupId>com.gruelbox</groupId>
<artifactId>transactionoutbox-jackson</artifactId>
<version>5.5.447</version>
</dependency>
implementation 'com.gruelbox:transactionoutbox-jackson:5.5.447'
See transactionoutbox-core for more information.
If starting with a fresh project, you don't need to worry about compatibility with DefaultInvocationSerializer, so configure as follows:
var outbox = TransactionOutbox.builder()
.persistor(DefaultPersistor.builder()
.dialect(Dialect.H2)
.serializer(JacksonInvocationSerializer.builder()
.mapper(new ObjectMapper())
.build())
.build())
If you're already using Transaction Outbox, you may have outbox tasks queued which your application needs to continue to be capable of loading.
To handle this, pass through an instance of DefaultInvocationSerializer
which matches what you used previously:
var outbox = TransactionOutbox.builder()
.persistor(DefaultPersistor.builder()
.dialect(Dialect.H2)
.serializer(JacksonInvocationSerializer.builder()
.mapper(new ObjectMapper())
.defaultInvocationSerializer(DefaultInvocationSerializer.builder()
.serializableTypes(Set.of(Foo.class, Bar.class))
.build())
.build())
.build())
You can now go wild with your scheduled method arguments:
outbox.schedule(getClass())
.process(List.of(LocalDate.of(2000,1,1), "a", "b", 2));