Outbox Handler
interface OutboxHandler
Content copied to clipboard
OutboxHandler is responsible for:
handling the outbox item
serializing the payload
calculating the next execution time
checking if the max retries has been reached
handling the payload and
handling the failure.
Example:
class MyOutboxHandler : OutboxHandler {
override fun getSupportedType(): OutboxType {
return MyOutboxType
}
override fun serialize(payload: OutboxPayload): String {
return payload.toString()
}
override fun getNextExecutionTime(currentRetries: Long): Instant {
return Instant.now()
}
override fun hasReachedMaxRetries(retries: Long): Boolean {
return retries >= 3
}
override fun handle(payload: String) {
// handle the payload
}
override fun handleFailure(payload: String) {
// handle the failure
// e.g. send an email to the admin
}
}
Functions
get Next Execution Time
Link copied to clipboard
Returns the next execution time for the outbox item.
get Retention Duration
Link copied to clipboard
Returns the amount of time that the outbox items of this handler's type should be retained. The outbox items will be deleted after this amount of time has passed after their completion.
get Supported Type
Link copied to clipboard
Returns the type of the outbox item that this handler can handle.
handle Failure
Link copied to clipboard
Handles the outbox item when it has reached the maximum number of retries.
has Reached Max Retries
Link copied to clipboard
Returns true if the outbox item has reached the maximum number of retries.
serialize
Link copied to clipboard
Serializes the payload into a string.
Inheritors
SimpleOutboxHandler
Link copied to clipboard