Skip to content

Commit

Permalink
Support for eventuate-tram/eventuate-tram-sagas#82 (CommandReplyProdu…
Browse files Browse the repository at this point in the history
…cer) and eventuate-foundation/eventuate-common#118 (IdGenerator signature)
  • Loading branch information
cer committed Oct 3, 2022
1 parent a8aadaa commit e80d01a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docker-compose-mssql.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: "3"
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.2.4
image: eventuateio/eventuate-zookeeper:$EVENTUATE_COMMON_VERSION
ports:
- 2181:2181
environment:
ZOOKEEPER_CLIENT_PORT: 2181

kafka:
image: "confluentinc/cp-kafka:5.2.4"
image: "eventuateio/eventuate-kafka:$EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION"
ports:
- 9092:9092
depends_on:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: "3"
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.2.4
image: eventuateio/eventuate-zookeeper:$EVENTUATE_COMMON_VERSION
ports:
- 2181:2181
environment:
ZOOKEEPER_CLIENT_PORT: 2181

kafka:
image: "confluentinc/cp-kafka:5.2.4"
image: "eventuateio/eventuate-kafka:$EVENTUATE_MESSAGING_KAFKA_IMAGE_VERSION"
ports:
- 9092:9092
depends_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

import javax.inject.Inject;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import static org.junit.jupiter.api.Assertions.*;


@QuarkusTest
Expand All @@ -21,23 +20,23 @@ public class SagaLockManagerIntegrationTest {
@Inject
SagaLockManager sagaLockManager;

private IdGenerator idGenerator = new ApplicationIdGenerator();
private final IdGenerator idGenerator = new ApplicationIdGenerator();

String sagaType = "mySagaType";

@Test
public void shouldClaimLock() {
String sagaId = idGenerator.genId(null).toString();
String target = "/target/" + idGenerator.genId(null).toString();
String sagaId = idGenerator.genIdAsString();
String target = "/target/" + idGenerator.genIdAsString();

assertTrue(sagaLockManager.claimLock(sagaType, sagaId, target));
}

@Test
public void shouldNotClaimLock() {
String sagaId1 = idGenerator.genId(null).toString();
String sagaId2 = idGenerator.genId(null).toString();
String target = "/target/" + idGenerator.genId(null).toString();
String sagaId1 = idGenerator.genIdAsString();
String sagaId2 = idGenerator.genIdAsString();
String target = "/target/" + idGenerator.genIdAsString();

assertTrue(sagaLockManager.claimLock(sagaType, sagaId1, target));
assertFalse(sagaLockManager.claimLock(sagaType, sagaId2, target));
Expand All @@ -46,20 +45,20 @@ public void shouldNotClaimLock() {

@Test
public void shouldStashMessage() {
String sagaId = idGenerator.genId(null).toString();
String target = "/target/" + idGenerator.genId(null).toString();
String messageId = idGenerator.genId(null).toString();
String sagaId = idGenerator.genIdAsString();
String target = "/target/" + idGenerator.genIdAsString();
String messageId = idGenerator.genIdAsString();

Message message = MessageBuilder.withPayload("hello").withHeader(Message.ID, messageId).build();
sagaLockManager.stashMessage(sagaType, sagaId, target, message);
}

@Test
public void shouldReleaseLockAndUnstashMessage() {
String sagaId1 = idGenerator.genId(null).toString();
String sagaId2 = idGenerator.genId(null).toString();
String target = "/target/" + idGenerator.genId(null).toString();
String messageId = idGenerator.genId(null).toString();
String sagaId1 = idGenerator.genIdAsString();
String sagaId2 = idGenerator.genIdAsString();
String target = "/target/" + idGenerator.genIdAsString();
String messageId = idGenerator.genIdAsString();

assertTrue(sagaLockManager.claimLock(sagaType, sagaId1, target));
assertFalse(sagaLockManager.claimLock(sagaType, sagaId2, target));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.eventuate.tram.sagas.quarkus.participant;

import io.eventuate.tram.commands.common.CommandNameMapping;
import io.eventuate.tram.commands.consumer.CommandReplyProducer;
import io.eventuate.tram.messaging.consumer.MessageConsumer;
import io.eventuate.tram.messaging.producer.MessageProducer;
import io.eventuate.tram.sagas.common.SagaLockManager;
import io.eventuate.tram.sagas.participant.SagaCommandDispatcherFactory;

Expand All @@ -13,8 +13,8 @@
public class SagaParticipantFactory {
@Singleton
public SagaCommandDispatcherFactory sagaCommandDispatcherFactory(Instance<MessageConsumer> messageConsumer,
Instance<MessageProducer> messageProducer,
Instance<CommandReplyProducer> commandReplyProducer,
SagaLockManager sagaLockManager, CommandNameMapping commandNameMapping) {
return new SagaCommandDispatcherFactory(messageConsumer.get(), messageProducer.get(), sagaLockManager, commandNameMapping);
return new SagaCommandDispatcherFactory(messageConsumer.get(), sagaLockManager, commandNameMapping, commandReplyProducer.get());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.eventuate.tram.sagas.quarkus.testing;

import io.eventuate.tram.commands.common.CommandNameMapping;
import io.eventuate.tram.commands.consumer.CommandReplyProducer;
import io.eventuate.tram.messaging.consumer.MessageConsumer;
import io.eventuate.tram.messaging.producer.MessageProducer;
import io.eventuate.tram.sagas.testing.SagaParticipantChannels;
import io.eventuate.tram.sagas.testing.SagaParticipantStubManager;

Expand All @@ -15,7 +15,7 @@ public class SagaParticipantStubManagerConfiguration {
@Singleton
public SagaParticipantStubManager sagaParticipantStubManager(Instance<SagaParticipantChannels> sagaParticipantChannels,
Instance<MessageConsumer> messageConsumer,
Instance<MessageProducer> messageProducer, Instance<CommandNameMapping> commandNameMapping) {
return new SagaParticipantStubManager(sagaParticipantChannels.get(), messageConsumer.get(), messageProducer.get(), commandNameMapping.get());
Instance<CommandReplyProducer> commandReplyProducer, Instance<CommandNameMapping> commandNameMapping) {
return new SagaParticipantStubManager(sagaParticipantChannels.get(), messageConsumer.get(), commandNameMapping.get(), commandReplyProducer.get());
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip

0 comments on commit e80d01a

Please sign in to comment.