Interface MessageKeyGenerator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface MessageKeyGenerator
Author:
Dave Syer, Gary Russell, Artem Bilan
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Object
    getKey(Message message)
    Generate a unique key for the message that is repeatable on redelivery.
  • Method Details

    • getKey

      @Nullable Object getKey(Message message)
      Generate a unique key for the message that is repeatable on redelivery. Implementations should be very careful about assuming uniqueness of any element of the message, especially considering the requirement that it be repeatable. A message id is ideal but may not be present (AMQP does not mandate it), and the message body is a byte array whose contents might be repeatable, but its object value is not.

      When returning null, the target service is called immediately and no retry is attempted anymore. This can be helpful in some scenarios when no more stateful retries are needed for the message, and it should be rejected after the service call failure.

      Parameters:
      message - the message to generate a key for
      Returns:
      a unique key for this message or null to reject the message if the call fails