@Bean @Profile("PostgresWal") public DbLogClient<MessageWithDestination> dbLogClient(@Value("${spring.datasource.url}") String dbUrl, @Value("${spring.datasource.username}") String dbUserName, @Value("${spring.datasource.password}") String dbPassword, EventuateConfigurationProperties eventuateConfigurationProperties, PostgresWalMessageParser<MessageWithDestination> postgresWalMessageParser) { return new PostgresWalClient<>(postgresWalMessageParser, dbUrl, dbUserName, dbPassword, eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection(), eventuateConfigurationProperties.getPostgresWalIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationStatusIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationSlotName()); }
@Bean public DbLogClient<PublishedEvent> dbLogClient(@Value("${spring.datasource.url}") String dbUrl, @Value("${spring.datasource.username}") String dbUserName, @Value("${spring.datasource.password}") String dbPassword, EventuateConfigurationProperties eventuateConfigurationProperties, PostgresWalMessageParser<PublishedEvent> postgresWalMessageParser) { return new PostgresWalClient<>(postgresWalMessageParser, dbUrl, dbUserName, dbPassword, eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection(), eventuateConfigurationProperties.getPostgresWalIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationStatusIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationSlotName()); }
@Bean @Profile("PostgresWal") public DbLogClient<MessageWithDestination> dbLogClient(@Value("${spring.datasource.url}") String dbUrl, @Value("${spring.datasource.username}") String dbUserName, @Value("${spring.datasource.password}") String dbPassword, EventuateConfigurationProperties eventuateConfigurationProperties, PostgresWalMessageParser<MessageWithDestination> postgresWalMessageParser) { return new PostgresWalClient<>(postgresWalMessageParser, dbUrl, dbUserName, dbPassword, eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection(), eventuateConfigurationProperties.getPostgresWalIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationStatusIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationSlotName()); }
@Bean @Profile("PostgresWal") public PostgresWalClient<PublishedEvent> postgresWalClient(@Value("${spring.datasource.url}") String dbUrl, @Value("${spring.datasource.username}") String dbUserName, @Value("${spring.datasource.password}") String dbPassword, EventuateConfigurationProperties eventuateConfigurationProperties, PostgresWalMessageParser<PublishedEvent> postgresWalMessageParser) { return new PostgresWalClient<>(postgresWalMessageParser, dbUrl, dbUserName, dbPassword, eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection(), eventuateConfigurationProperties.getPostgresWalIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationStatusIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationSlotName()); }
@Test public void shouldGetEvents() throws InterruptedException{ PostgresWalClient<PublishedEvent> postgresWalClient = new PostgresWalClient<>(postgresWalMessageParser, dataSourceURL, dbUserName, dbPassword, eventuateConfigurationProperties.getBinlogConnectionTimeoutInMilliseconds(), eventuateConfigurationProperties.getMaxAttemptsForBinlogConnection(), eventuateConfigurationProperties.getPostgresWalIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationStatusIntervalInMilliseconds(), eventuateConfigurationProperties.getPostgresReplicationSlotName()); BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>(); postgresWalClient.start(Optional.empty(), publishedEvents::add); String accountCreatedEventData = generateAccountCreatedEvent(); EntityIdVersionAndEventIds saveResult = saveEvent(accountCreatedEventData); String accountDebitedEventData = generateAccountDebitedEvent(); EntityIdVersionAndEventIds updateResult = updateEvent(saveResult.getEntityId(), saveResult.getEntityVersion(), accountDebitedEventData); // Wait for 10 seconds LocalDateTime deadline = LocalDateTime.now().plusSeconds(10); waitForEvent(publishedEvents, saveResult.getEntityVersion(), deadline, accountCreatedEventData); waitForEvent(publishedEvents, updateResult.getEntityVersion(), deadline, accountDebitedEventData); postgresWalClient.stop(); }