Last active
October 6, 2022 12:58
-
-
Save harishb2k/a8241f13e13c116e1b4d0525bc1290ab to your computer and use it in GitHub Desktop.
Revisions
-
harishb2k revised this gist
Oct 6, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ messaging.producers.updateUserEvent.brokers: localhost:9092 messaging.producers.updateUserEvent.sync: true messaging.producers.updateUserEvent.enableCircuitBreakerOnError: true messaging.producers.updateUserEvent.request-timeout-ms: 100 messaging.producers.updateUserEvent.ack: all messaging.producers.updateUserEvent.circuit-breaker-stay_in_open_state_on_error-ms: 10000 ``` -
harishb2k revised this gist
Sep 22, 2022 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,14 @@ messaging.producers.updateUserEvent.topic: topic_123 messaging.producers.updateUserEvent.brokers: localhost:9092 messaging.producers.updateUserEvent.sync: true messaging.producers.updateUserEvent.enableCircuitBreakerOnError: true messaging.producers.updateUserEvent.request-timeout-ms: 100 messaging.producers.updateUserEvent.ack: 1 messaging.producers.updateUserEvent.circuit-breaker-stay_in_open_state_on_error-ms: 10000 ``` Note you can use other kafka properties e.g. linger.ms or batch.size. Since this is a property file use "-" instead of "." for kafka properties e.g. Kafka property is "request.timeout.ms" but in config you must have "request-timeout-ms" What is ```enableCircuitBreakerOnError``` setting? Suppose you have some error in your kafka setup. Setting ```enableCircuitBreakerOnError=true``` will open a circuit (circuit breaker) and will ensure your service does not fail. Please note - when circuit is open, messages are dropped to ensure application resiliency(standard circiut breaker approch) -
harishb2k revised this gist
Sep 22, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ messaging.producers.updateUserEvent.topic: topic_123 messaging.producers.updateUserEvent.brokers: localhost:9092 messaging.producers.updateUserEvent.sync: true messaging.producers.updateUserEvent.enableCircuitBreakerOnError: true messaging.producers.updateUserEvent.request_timeout_ms: 100 messaging.producers.updateUserEvent.ack: 1 messaging.producers.updateUserEvent.circuit-breaker.stay_in_open_state_on_error.ms: 10000 ``` -
harishb2k revised this gist
Jul 8, 2022 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ ``` # Messaging to send events to update user event # Update the Kafka and topic name for your own setup messaging.producers.updateUserEvent.enabled: true messaging.producers.updateUserEvent.topic: topic_123 messaging.producers.updateUserEvent.brokers: localhost:9092 @@ -8,4 +9,10 @@ messaging.producers.updateUserEvent.enableCircuitBreakerOnError: true messaging.producers.updateUserEvent.request.timeout.ms: 100 messaging.producers.updateUserEvent.ack: 1 messaging.producers.updateUserEvent.circuit-breaker.stay_in_open_state_on_error.ms: 10000 ``` What is ```enableCircuitBreakerOnError``` setting? Suppose you have some error in your kafka setup. Setting ```enableCircuitBreakerOnError=true``` will open a circuit (circuit breaker) and will ensure your service does not fail. Please note - when circuit is open, messages are dropped to ensure application resiliency(standard circiut breaker approch) Use ```circuit-breaker.stay_in_open_state_on_error.ms``` to specify how long circuit will remain open, before retrying. -
harishb2k renamed this gist
Jul 8, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
harishb2k revised this gist
Jul 8, 2022 . 1 changed file with 44 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ ```java import io.gitbub.devlibx.easy.helper.metrics.IMetrics; import io.gitbub.devlibx.easy.helper.string.StringHelper; import io.github.devlibx.easy.messaging.config.MessagingConfigs; import io.github.devlibx.easy.messaging.consumer.IConsumerService; import io.github.devlibx.easy.messaging.kafka.consumer.KafkaBasedConsumerService; import io.github.devlibx.easy.messaging.kafka.producer.KafkaBasedProducerService; import io.github.devlibx.easy.messaging.producer.IProducerService; import io.github.devlibx.easy.messaging.service.IMessagingFactory; import io.github.devlibx.easy.messaging.service.MessageFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.Map; @Configuration public class MessagingConfigurationBeanFactory { @Bean public StringHelper stringHelper() { return new StringHelper(); } @Bean public IMetrics metrics() { return new IMetrics.NoOpMetrics(); } @Bean @Autowired public IMessagingFactory messagingFactory(MessagingConfigs messagingConfigs, StringHelper stringHelper, IMetrics metrics) { Map<String, IProducerService> producerServiceMap = new HashMap<>(); producerServiceMap.put("KAFKA", new KafkaBasedProducerService(stringHelper, metrics)); Map<String, IConsumerService> consumerServiceMap = new HashMap<>(); consumerServiceMap.put("KAFKA", new KafkaBasedConsumerService(metrics)); IMessagingFactory messagingFactory = new MessageFactory(producerServiceMap, consumerServiceMap, messagingConfigs); messagingFactory.initialize(); return messagingFactory; } } ``` -
harishb2k revised this gist
Jul 8, 2022 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ ```java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @Getter @Setter @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) @Configuration @ConfigurationProperties(prefix = "messaging") public class MessagingConfigs extends io.github.devlibx.easy.messaging.config.MessagingConfigs { } ``` -
harishb2k created this gist
Jul 8, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ ``` # Messaging to send events to update user event messaging.producers.updateUserEvent.enabled: true messaging.producers.updateUserEvent.topic: topic_123 messaging.producers.updateUserEvent.brokers: localhost:9092 messaging.producers.updateUserEvent.sync: true messaging.producers.updateUserEvent.enableCircuitBreakerOnError: true messaging.producers.updateUserEvent.request.timeout.ms: 100 messaging.producers.updateUserEvent.ack: 1 messaging.producers.updateUserEvent.circuit-breaker.stay_in_open_state_on_error.ms: 10000 ```