use of io.eventuate.local.common.JdbcUrl in project eventuate-local by eventuate-local.
the class AbstractMySqlBinlogCdcIntegrationTest method shouldGetEvents.
@Test
public void shouldGetEvents() throws InterruptedException {
JdbcUrl jdbcUrl = JdbcUrlParser.parse(dataSourceURL);
MySqlBinaryLogClient<PublishedEvent> mySqlBinaryLogClient = new MySqlBinaryLogClient<>(eventDataParser, eventuateConfigurationProperties.getDbUserName(), eventuateConfigurationProperties.getDbPassword(), jdbcUrl.getHost(), jdbcUrl.getPort(), eventuateConfigurationProperties.getBinlogClientId(), sourceTableNameSupplier.getSourceTableName(), eventuateConfigurationProperties.getMySqlBinLogClientName(), eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection());
EventuateLocalAggregateCrud localAggregateCrud = new EventuateLocalAggregateCrud(eventuateJdbcAccess);
BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>();
mySqlBinaryLogClient.start(Optional.empty(), publishedEvents::add);
String accountCreatedEventData = generateAccountCreatedEvent();
EntityIdVersionAndEventIds saveResult = saveEvent(localAggregateCrud, accountCreatedEventData);
String accountDebitedEventData = generateAccountDebitedEvent();
EntityIdVersionAndEventIds updateResult = updateEvent(saveResult.getEntityId(), saveResult.getEntityVersion(), localAggregateCrud, accountDebitedEventData);
// Wait for 10 seconds
LocalDateTime deadline = LocalDateTime.now().plusSeconds(10);
waitForEvent(publishedEvents, saveResult.getEntityVersion(), deadline, accountCreatedEventData);
waitForEvent(publishedEvents, updateResult.getEntityVersion(), deadline, accountDebitedEventData);
mySqlBinaryLogClient.stop();
}
Aggregations