private void takeLeadership() throws InterruptedException { logger.info("Taking leadership"); try { eventTableChangesToAggregateTopicTranslator.startCapturingChanges(); } catch (Throwable t) { logger.error("In takeLeadership", t); throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t); } finally { logger.debug("TakeLeadership returning"); } }
private void resignLeadership() { logger.info("Resigning leadership"); try { eventTableChangesToAggregateTopicTranslator.stopCapturingChanges(); } catch (InterruptedException e) { logger.error("While handling SUSPEND", e); } } }
@Bean public EventTableChangesToAggregateTopicTranslator<PublishedEvent> mySqlEventTableChangesToAggregateTopicTranslator(CdcDataPublisher<PublishedEvent> mySQLCdcDataPublisher, CdcProcessor<PublishedEvent> mySQLCdcProcessor, CuratorFramework curatorFramework, EventuateConfigurationProperties eventuateConfigurationProperties) { return new EventTableChangesToAggregateTopicTranslator<>(mySQLCdcDataPublisher, mySQLCdcProcessor, curatorFramework, eventuateConfigurationProperties.getLeadershipLockPath()); }
@Bean public EventTableChangesToAggregateTopicTranslator<MessageWithDestination> eventTableChangesToAggregateTopicTranslator(EventuateConfigurationProperties eventuateConfigurationProperties, CdcDataPublisher<MessageWithDestination> cdcKafkaPublisher, CdcProcessor<MessageWithDestination> cdcProcessor, CuratorFramework curatorFramework) { return new EventTableChangesToAggregateTopicTranslator<>(cdcKafkaPublisher, cdcProcessor, curatorFramework, eventuateConfigurationProperties.getLeadershipLockPath()); }
@Bean public EventTableChangesToAggregateTopicTranslator<MessageWithDestination> eventTableChangesToAggregateTopicTranslator(EventuateConfigurationProperties eventuateConfigurationProperties, CdcDataPublisher<MessageWithDestination> cdcKafkaPublisher, CdcProcessor<MessageWithDestination> cdcProcessor, CuratorFramework curatorFramework) { return new EventTableChangesToAggregateTopicTranslator<>(cdcKafkaPublisher, cdcProcessor, curatorFramework, eventuateConfigurationProperties.getLeadershipLockPath()); }
public void startCapturingChanges() throws InterruptedException { logger.debug("Starting to capture changes"); cdcDataPublisher.start(); try { cdcProcessor.start(cdcDataPublisher::handleEvent); } catch (Exception e) { if (e.getCause() instanceof EventuateLocalPublishingException) { logger.error("Stopping capturing changes due to exception:", e); this.stopCapturingChanges(); } } logger.debug("Started CDC Kafka publisher"); }