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
| @Bean | |
| RetryTemplate retryTemplate() { | |
| RetryTemplate retryTemplate = new RetryTemplate() | |
| FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy() | |
| fixedBackOffPolicy.setBackOffPeriod(1000l) | |
| retryTemplate.setBackOffPolicy(fixedBackOffPolicy) | |
| SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy() | |
| retryPolicy.setMaxAttempts(2) |
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
| plugins { | |
| id 'java' | |
| id 'com.diffplug.gradle.spotless' version '3.26.1' | |
| // other plugins | |
| } | |
| repositories { .. } | |
| dependencies { .. } |
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
| @Component | |
| public class SpringContext implements ApplicationContextAware { | |
| private static ApplicationContext context; | |
| @Override | |
| public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| context = applicationContext; | |
| } | |
| public static <T> T getBean(Class<T> beanClass) { |
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
| public class CustomExceptionHandler implements ProductionExceptionHandler { | |
| private ExceptionService exceptionService; | |
| public ProductionExceptionHandlerResponse handle(final ProducerRecord<byte[], byte[]> record, final Exception exception) { | |
| boolean shouldContinue = exceptionService.handleProductionException(record, exception); | |
| return shouldContinue ? CONTINUE : FAIL; | |
| } |
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
| KafkaStreams streams = new KafkaStreams(topology, config); | |
| // other configurations | |
| streams.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> { | |
| // examine the throwable and do something | |
| }); | |
| streams.start(); |
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
| public class ContainerKafkaTestResource implements QuarkusTestResourceLifecycleManager { | |
| private static final KafkaContainer kafka = new KafkaContainer(); | |
| /** | |
| * @return A map of system properties that should be set for the running tests | |
| */ | |
| @Override | |
| public Map<String, String> start() { | |
| kafka.start(); |
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
| @QuarkusTest | |
| @QuarkusTestResource(ContainerKafkaTestResource.class) | |
| @Stereotype | |
| @Retention(RetentionPolicy.RUNTIME) | |
| @Target(ElementType.TYPE) | |
| @DisabledIfSystemProperty(named = "container-enabled", matches = "false") | |
| public @interface QuarkusContainerKafkaTest {} |
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
| @QuarkusContainerKafkaTest | |
| public class ExampleTest { | |
| ... | |
| } |
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
| import org.springframework.kafka.test.EmbeddedKafkaBroker; | |
| public class EmbeddedKafkaTestResource implements QuarkusTestResourceLifecycleManager { | |
| public EmbeddedKafkaBroker embeddedBroker; | |
| /** | |
| * @return A map of system properties that should be set for the running test | |
| */ | |
| @Override |
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
| @QuarkusTest | |
| @QuarkusTestResource(EmbeddedKafkaTestResource.class) | |
| @Stereotype | |
| @Target(ElementType.TYPE) | |
| @Retention(RetentionPolicy.RUNTIME) | |
| public @interface QuarkusEmbeddedKafkaTest {} |