Last active
July 16, 2021 10:07
-
-
Save vishalg0wda/7f7f5e9b41462f11feff3b027f4df4ae to your computer and use it in GitHub Desktop.
Composite annotation that applies required property overrides and proxies other commonly used parameters to meta annotations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.booking.payments.point.common.core.annotation; | |
import com.booking.payments.point.common.core.model.MetricNames; | |
import io.micrometer.core.annotation.Timed; | |
import java.lang.annotation.Documented; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import org.springframework.beans.factory.annotation.Qualifier; | |
import org.springframework.core.annotation.AliasFor; | |
import org.springframework.kafka.annotation.KafkaListener; | |
/** | |
* Composite annotation for Kafka Consumers of the pay-notifications topics. | |
* - Applies kafka-client property overrides required for cluster-discovery (used in booking-kafka-clients). | |
* - Applies a {@link Timed} annotation. | |
* Proxies all other commonly used parameters to original annotations. | |
*/ | |
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE}) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Documented | |
@Timed | |
@KafkaListener( | |
properties = { | |
"cluster.dc = ${pay-notifications.kafka-cluster.dc}", | |
"cluster.env = ${pay-notifications.kafka-cluster.env}", | |
} | |
) | |
public @interface PayNotificationListener { | |
@AliasFor(annotation = Timed.class, attribute = "value") | |
String metricName() default MetricNames.UOW_PAY_NOTIFICATION_BATCH; | |
@AliasFor(annotation = KafkaListener.class, attribute = "topics") | |
String[] topics(); | |
@AliasFor(annotation = KafkaListener.class, attribute = "clientIdPrefix") | |
String clientIdPrefix() default "pay-notifications"; | |
@AliasFor(annotation = KafkaListener.class, attribute = "concurrency") | |
String concurrency() default ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment