Package overit.geocall.event.consumer
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 Summary
Modifier and TypeMethodDescriptioncheckTopicSegregation(ConsumerProperties properties) check if the propertiesConsumerProperties.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 prefixvoiddecreaseNThreads(int threads) Decrease the number of threads for the current consumervoiddestroy()Delete the consumerintGet the current number of threadsvoidIn case of exception during the message consuming, the method will be invokedvoidincreaseNThreads(int threads) Increase the number of threads for the current consumervoidinit(@NotNull ConsumerProperties consumerProperties) Initialize the consumer with the properties passed
-
Method Details
-
checkTopicSegregation
check if the propertiesConsumerProperties.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
Initialize the consumer with the properties passed- Parameters:
consumerProperties- properties used to define the consumer
-
destroy
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 idmessage- body of the messagedlq- 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
-