The Integration API is currently available for Java only.
Concepts
An integration is a producer that sends invocations to Restate. Each invocation targets a service and handler, carries a payload, and is assigned an offset: a number that identifies its position in the stream the producer is sending. Restate uses the offset to order deliveries and to deduplicate them, which is what gives the integration its delivery guarantees. You choose the delivery semantics by choosing the producer type:- At-least-once, with
Producer. The client assigns the offset for you. Deduplication is off, so a record can be delivered more than once across restarts. - Exactly-once, with
ExactlyOnceProducer. You supply a deterministic offset per invocation, and Restate drops replays after a restart.
Both producers are
AutoCloseable. A producer is not thread-safe and fails fast if used from multiple threads. Create one producer per sending thread.At-least-once producer
UseProducer when your source does not have a stable, replayable position for each event.
The producer assigns a monotonically increasing offset to each invocation, and returns that offset from send.
Deduplication is disabled, so an invocation can be delivered more than once after a restart. Add an idempotency key on the invocation if you need handler-level deduplication.
Exactly-once producer
UseExactlyOnceProducer when your source can give each event a deterministic, strictly increasing offset, for example a log sequence number or a Kafka partition offset.
You pass that offset to send, and Restate deduplicates on the producer id and offset, dropping any replay that arrives after a restart.
Sending in order and applying backpressure
Await eachsend future before starting the next one.
This keeps the invocations in order and applies backpressure, since the future completes only once the producer has room to accept the next invocation.
For non-blocking sends, use trySend.
It attempts a send and throws ProducerNotReadyException when the send window is full.
Await waitReady() to be notified when capacity is available again:
Stream defaults
To set fields shared by every invocation once, pass anInvocationMetadata when building the producer.
Fields set per invocation override the stream defaults.
Acknowledgements
send completes once the invocation has been sent.
To confirm that Restate has durably accepted it, await an acknowledgement:
waitAcknowledged()waits for everything up tolastSentOffset().waitAcknowledged(offset)waits for a specific offset.