Payload
- The message type.
Note: This class is not meant to be extended by client code.
public interface Subscriber<Payload>
Modifier and Type | Interface and Description |
---|---|
static interface |
Subscriber.GroupId
Subscribers with the same group id belong to the same subscriber group.
|
Modifier and Type | Method and Description |
---|---|
CompletionStage<akka.Done> |
atLeastOnce(akka.stream.javadsl.Flow<Payload,akka.Done,?> flow)
Applies the passed
flow to the messages processed by this subscriber. |
akka.stream.javadsl.Source<Payload,?> |
atMostOnceSource()
Returns a stream of messages with at most once delivery semantic.
|
Subscriber<Payload> |
withGroupId(String groupId)
Returns a copy of this subscriber with the passed group id.
|
default Subscriber<Message<Payload>> |
withMetadata()
Returns this subscriber, but message payloads are wrapped in
Message instances to allow
accessing any metadata associated with the message. |
Subscriber<Payload> withGroupId(String groupId) throws IllegalArgumentException
groupId
- The group id to assign to this subscriber.IllegalArgumentException
- If the passed group id is illegal.default Subscriber<Message<Payload>> withMetadata()
Message
instances to allow
accessing any metadata associated with the message.akka.stream.javadsl.Source<Payload,?> atMostOnceSource()
If a failure occurs (e.g., an exception is thrown), the user is responsible of deciding how to recover from it (e.g., restarting the stream, aborting, ...).
CompletionStage<akka.Done> atLeastOnce(akka.stream.javadsl.Flow<Payload,akka.Done,?> flow)
flow
to the messages processed by this subscriber. Messages are
delivered to the passed flow
at least once.
If a failure occurs (e.g., an exception is thrown), the stream may be automatically restarted starting with the message that caused the failure.
Whether the stream is automatically restarted depends on the Lagom message broker implementation in use. If the Kafka Lagom message broker module is being used, then by default the stream is automatically restarted when a failure occurs.
The flow
may pull more elements from upstream but it must emit exactly one
Done
message for each message that it receives. It must also emit them in the same
order that the messages were received. This means that the flow
must not filter or
collect a subset of the messages, instead it must split the messages into separate streams and
map those that would have been dropped to Done
.
flow
- The flow to apply to each received message.CompletionStage
that may never complete if messages go through the
passed flow
flawlessly. However, the returned CompletionStage
may
complete with success if the passed flow
signals cancellation upstream.
If the returned CompletionStage
is completed with a failure, user-code is
responsible of deciding what to do (e.g., it could retry to process the message that caused
the failure, or it could report an application error).