Interface Consumer

All Known Implementing Classes:
SQSConsumer

public interface Consumer
Interface used to define the consumer lifecycle. It could be instanced using the init method or deleted by the destroy method. It's also possible define the behaviour in case of error during the consuming message and increase or decrease the number of threads
  • Method Details

    • checkTopicSegregation

      default List<String> checkTopicSegregation(ConsumerProperties properties)
      check if the properties ConsumerProperties.isTopicSegregation() is enabled and in that case: for the consumers defined on Company Config adds to the topics defined the id of the company as prefix for the consumers defined on System Config for each topic add the id of all companies defined as prefix
      Parameters:
      properties - properties defined for the consumer
      Returns:
      list of topics normalized in according to the property ConsumerProperties.isTopicSegregation()
    • init

      void init(@NotNull @NotNull ConsumerProperties consumerProperties)
      Initialize the consumer with the properties passed
      Parameters:
      consumerProperties - properties used to define the consumer
    • destroy

      void destroy() throws ConsumerException
      Delete the consumer
      Throws:
      ConsumerException - if it's not possible to stop the consumer
    • handleError

      void handleError(@NotNull @NotNull String id, @NotNull @NotNull String message, @NotNull @NotNull String dlq)
      In case of exception during the message consuming, the method will be invoked
      Parameters:
      id - message id
      message - body of the message
      dlq - dead letter queue to move the message
    • getCurrentNumberThreads

      int getCurrentNumberThreads()
      Get the current number of threads
      Returns:
      current number of threads
    • increaseNThreads

      void increaseNThreads(int threads)
      Increase the number of threads for the current consumer
      Parameters:
      threads - number of threads to increase
    • decreaseNThreads

      void decreaseNThreads(int threads)
      Decrease the number of threads for the current consumer
      Parameters:
      threads - number of threads to decrease