RabbitMQ Adapter
The RabbitMQ adapter is currently available for Java (xceptoj) only.
The RabbitMQ adapter listens for messages on a queue and transitions when a matching event arrives. It enables testing event-driven flows without polling an HTTP endpoint.
Setup
var rabbitmq = builder.registerAdapter(
new RabbitMqXceptoAdapter(
WarehouseRabbitMqConfig.getConfig(
scenario.getPort("rabbitmq", 5672))));
Wait for an event
eventCondition registers a step that transitions when a message matching the predicate arrives on the configured queue:
rabbitmq.eventCondition(StockReplenishedEvent.class, e -> e.total == 50);
The adapter deserializes incoming messages to the given type and evaluates the predicate. The step retries (continues consuming) until the condition is satisfied or the timeout expires.
Full example — REST command + event consequence
Xcepto.given(scenario, builder -> {
var rabbitmq = builder.registerAdapter(
new RabbitMqXceptoAdapter(
WarehouseRabbitMqConfig.getConfig(
scenario.getPort("rabbitmq", 5672))));
var rest = new RestAdapterBuilder(builder)
.withBaseUrl(URI.create("http://localhost:8081"))
.withSerializer(new GsonSerializer())
.build();
// Issue the command
rest.post("/shipment/accept")
.withRequestBody(() -> new AcceptShipmentRequest(50))
.withResponseType(AcceptShipmentResponse.class)
.assertThatResponse((AcceptShipmentResponse r) -> r.amount == 50);
// Wait for the domain event to propagate
rabbitmq.eventCondition(StockReplenishedEvent.class, e -> e.total == 50);
}, TIMEOUT, Duration.ofMillis(100));
Configuration
Consult your RabbitMqXceptoAdapter constructor for the configuration object expected by your setup. Typically this includes:
- Host and port (often read from scenario port bindings)
- Virtual host, username, password
- Queue name to listen on
The scenario exposes port bindings when using Docker Compose or Testcontainers to run RabbitMQ alongside the system under test.