Search in sources :

Example 1 with JdbcUrl

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();
}
Also used : EntityIdVersionAndEventIds(io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds) LocalDateTime(java.time.LocalDateTime) JdbcUrl(io.eventuate.local.common.JdbcUrl) EventuateLocalAggregateCrud(io.eventuate.local.java.jdbckafkastore.EventuateLocalAggregateCrud) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) PublishedEvent(io.eventuate.local.common.PublishedEvent) Test(org.junit.Test) AbstractCdcTest(io.eventuate.local.test.util.AbstractCdcTest)

Aggregations

EntityIdVersionAndEventIds (io.eventuate.javaclient.commonimpl.EntityIdVersionAndEventIds)1 JdbcUrl (io.eventuate.local.common.JdbcUrl)1 PublishedEvent (io.eventuate.local.common.PublishedEvent)1 EventuateLocalAggregateCrud (io.eventuate.local.java.jdbckafkastore.EventuateLocalAggregateCrud)1 AbstractCdcTest (io.eventuate.local.test.util.AbstractCdcTest)1 LocalDateTime (java.time.LocalDateTime)1 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1 Test (org.junit.Test)1