Interface Consumer.Context

All Known Subinterfaces:
Consumer.BatchContext
Enclosing interface:
Consumer

public static interface Consumer.Context
Context for message processing.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Accept the message (AMQP 1.0 accepted outcome).
    batch(int batchSizeHint)
    Create a batch context to accumulate message contexts and settle them at once.
    void
    Requeue the message for redelivery after the specified delay.
    void
    delayedRetry(Duration delay, boolean deliveryFailed)
    Requeue the message for redelivery after the specified delay.
    void
    delayedRetry(Instant deliveryTime)
    Requeue the message for redelivery at the specified time.
    void
    delayedRetry(Instant deliveryTime, boolean deliveryFailed)
    Requeue the message for redelivery at the specified time.
    void
    Discard the message (AMQP 1.0 rejected outcome).
    void
    discard(Map<String,Object> annotations)
    Discard the message with annotations to combine with the existing message annotations.
    void
    Requeue the message (AMQP 1.0 released outcome).
    void
    requeue(Map<String,Object> annotations)
    Requeue the message with annotations to combine with the existing message annotations.
    void
    requeue(Map<String,Object> annotations, boolean deliveryFailed)
    Requeue the message with annotations to combine with the existing message annotations.
  • Method Details

    • accept

      void accept()
      Accept the message (AMQP 1.0 accepted outcome).

      This means the message has been processed and the broker can delete it.

    • discard

      void discard()
      Discard the message (AMQP 1.0 rejected outcome).

      This means the message cannot be processed because it is invalid, the broker can drop it or dead-letter it if it is configured.

    • discard

      void discard(Map<String,Object> annotations)
      Discard the message with annotations to combine with the existing message annotations.

      This means the message cannot be processed because it is invalid, the broker can drop it or dead-letter it if it is configured.

      Custom application-specific annotation keys should start with the x-opt- prefix so they are safely ignored if not understood. Keys starting with x- (but not x-opt-) are reserved for broker-specific features, and unrecognized keys will cause a protocol error.

      This maps to the AMQP 1.0 modified{delivery-failed = true, undeliverable-here = true} outcome.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      annotations - message annotations to combine with existing ones
      See Also:
    • requeue

      void requeue()
      Requeue the message (AMQP 1.0 released outcome).

      This means the message has not been processed and the broker can requeue it and deliver it to the same or a different consumer.

    • requeue

      void requeue(Map<String,Object> annotations)
      Requeue the message with annotations to combine with the existing message annotations.

      This means the message has not been processed and the broker can requeue it and deliver it to the same or a different consumer.

      Custom application-specific annotation keys should start with the x-opt- prefix so they are safely ignored if not understood. Keys starting with x- (but not x-opt-) are reserved for broker-specific features, and unrecognized keys will cause a protocol error.

      This maps to the AMQP 1.0 modified{delivery-failed = false, undeliverable-here = false} outcome.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      annotations - message annotations to combine with existing ones
      See Also:
    • requeue

      void requeue(Map<String,Object> annotations, boolean deliveryFailed)
      Requeue the message with annotations to combine with the existing message annotations.

      This means the message has not been processed and the broker can requeue it and deliver it to the same or a different consumer.

      Custom application-specific annotation keys should start with the x-opt- prefix so they are safely ignored if not understood. Keys starting with x- (but not x-opt-) are reserved for broker-specific features, and unrecognized keys will cause a protocol error.

      This maps to the AMQP 1.0 modified{delivery-failed = deliveryFailed, undeliverable-here = false} outcome.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      annotations - message annotations to combine with existing ones
      deliveryFailed - if true, the delivery count of the message is incremented
      See Also:
    • delayedRetry

      void delayedRetry(Duration delay)
      Requeue the message for redelivery after the specified delay.

      This maps to the AMQP 1.0 modified{delivery-failed = false, undeliverable-here = false} outcome with the x-opt-delivery-time annotation set to now + delay.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      delay - delivery delay from now
      See Also:
    • delayedRetry

      void delayedRetry(Duration delay, boolean deliveryFailed)
      Requeue the message for redelivery after the specified delay.

      This maps to the AMQP 1.0 modified{delivery-failed = false, undeliverable-here = false} outcome with the x-opt-delivery-time annotation set to now + delay.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      delay - delivery delay from now
      deliveryFailed - if true, the delivery count of the message is incremented
      See Also:
    • delayedRetry

      void delayedRetry(Instant deliveryTime)
      Requeue the message for redelivery at the specified time.

      This maps to the AMQP 1.0 modified{delivery-failed = false, undeliverable-here = false} outcome with the x-opt-delivery-time annotation set to the specified time.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      deliveryTime - absolute delivery time
      See Also:
    • delayedRetry

      void delayedRetry(Instant deliveryTime, boolean deliveryFailed)
      Requeue the message for redelivery at the specified time.

      This maps to the AMQP 1.0 modified{delivery-failed = false, undeliverable-here = false} outcome with the x-opt-delivery-time annotation set to the specified time.

      Only quorum queues support the modification of message annotations with the modified outcome.

      Parameters:
      deliveryTime - absolute delivery time
      deliveryFailed - if true, the delivery count of the message is incremented
      See Also:
    • batch

      Consumer.BatchContext batch(int batchSizeHint)
      Create a batch context to accumulate message contexts and settle them at once.

      The message context the batch context is created from is not added to the batch context.

      Returns:
      the created batch context