A
- a representation of an action command that is shared across all actions in the saga. This is typically a generic type, such as Json, or if using Avro serialization, SpecificRecord or GenericRecordpublic final class KafkaSagaAPI<A> extends Object implements SagaAPI<A>
This provides a mechanism to invoke a saga from any Java code, and receive the saga response asynchronously.
The client can be hosted in a separate process. It only needs to be able to access the same cluster as the SagaApp is running on, and share the same serdes for the saga request and response topics.
Modifier and Type | Method and Description |
---|---|
io.simplesource.data.FutureResult<SagaError,SagaResponse> |
getSagaResponse(SagaId sagaId,
java.time.Duration timeout)
Returns the result of the saga.
|
io.simplesource.data.FutureResult<SagaError,SagaId> |
submitSaga(SagaRequest<A> request)
Initiates a saga.
|
public io.simplesource.data.FutureResult<SagaError,SagaId> submitSaga(SagaRequest<A> request)
SagaAPI
This does not return the result of the saga, just an indication of whether the request was published successfully or not.
We call the getSagaResponse
method to asychronously return the result of the saga.
submitSaga
in interface SagaAPI<A>
request
- the requestpublic io.simplesource.data.FutureResult<SagaError,SagaResponse> getSagaResponse(SagaId sagaId, java.time.Duration timeout)
SagaAPI
getSagaResponse
in interface SagaAPI<A>
sagaId
- the saga id for the saga initiated by calling submitSaga
.timeout
- the timeoutCopyright © 2019. All rights reserved.