Skip to content

Latest commit

 

History

History
83 lines (61 loc) · 2.88 KB

File metadata and controls

83 lines (61 loc) · 2.88 KB

transaction-outbox-jackson

Jackson on Maven Central Jackson Javadoc Latest snapshot

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.

Installation

Stable releases

Maven

<dependency>
  <groupId>com.gruelbox</groupId>
  <artifactId>transactionoutbox-jackson</artifactId>
  <version>5.5.447</version>
</dependency>

Gradle

implementation 'com.gruelbox:transactionoutbox-jackson:5.5.447'

Development snapshots

See transactionoutbox-core for more information.

Configuration

Fresh projects

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())

Existing projects using DefaultInvocationSerializer

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())

Usage

You can now go wild with your scheduled method arguments:

outbox.schedule(getClass())
  .process(List.of(LocalDate.of(2000,1,1), "a", "b", 2));