Interface Consumer.Effect.Builder

Enclosing interface:
Consumer.Effect

public static interface Consumer.Effect.Builder
Builder for constructing Consumer effects that describe what the runtime should do after message processing.
  • Method Details

    • done

      Mark the message as successfully processed.

      Use this when the message has been processed and no further action is needed.

      Returns:
      an Effect indicating successful message processing
    • asyncDone

      Consumer.Effect asyncDone(CompletionStage<akka.Done> message)
      Mark the message as processed from an async operation result.

      Use this when message processing involves asynchronous operations that complete with a Done result.

      Parameters:
      message - the future result of the async operation
      Returns:
      an Effect that will complete when the async operation completes
    • produce

      <S> Consumer.Effect produce(S message)
      Produce a message to a topic or service stream.

      This is used when the Consumer is also configured as a producer with @Produce.ToTopic or @Produce.ServiceStream annotations. The message will be published using CloudEvents format.

      Type Parameters:
      S - the type of the message
      Parameters:
      message - the payload of the message to produce
      Returns:
      an Effect that will produce the message
    • produce

      <S> Consumer.Effect produce(S message, Metadata metadata)
      Produce a message with custom metadata to a topic or service stream.

      Use this when you need to include additional metadata with the produced message, such as CloudEvent attributes or custom headers. To guarantee message ordering, include the entity id as the subject in the metadata.

      Type Parameters:
      S - the type of the message
      Parameters:
      message - the payload of the message to produce
      metadata - the metadata to include with the message
      Returns:
      an Effect that will produce the message with the specified metadata
    • asyncProduce

      <S> Consumer.Effect asyncProduce(CompletionStage<S> message)
      Produce a message from an async operation result.

      Use this when the message to be produced is the result of an asynchronous operation.

      Type Parameters:
      S - the type of the message
      Parameters:
      message - the future payload of the message to produce
      Returns:
      an Effect that will produce the message when the async operation completes
    • asyncProduce

      <S> Consumer.Effect asyncProduce(CompletionStage<S> message, Metadata metadata)
      Produce a message from an async operation result with custom metadata.

      Combines async message production with custom metadata.

      Type Parameters:
      S - the type of the message
      Parameters:
      message - the future payload of the message to produce
      metadata - the metadata to include with the message
      Returns:
      an Effect that will produce the message with metadata when the async operation completes
    • asyncEffect

      Consumer.Effect asyncEffect(CompletionStage<Consumer.Effect> futureEffect)
      Create an effect from an async operation that returns an effect.

      Use this when the effect to be applied depends on the result of an asynchronous operation.

      Parameters:
      futureEffect - the future effect to apply
      Returns:
      an Effect that will apply the future effect when it completes
    • ignore

      Consumer.Effect ignore()
      Ignore the current message and proceed with processing the next message.

      Use this to filter out messages that should not be processed, such as events that are not relevant to the Consumer's logic. The message will be acknowledged but no further processing occurs.

      Returns:
      an Effect that ignores the current message