Class AsyncApiMockOrchestrator
MessagePublisher.
Supports one-shot publishing (publishAll()) and scheduled
periodic publishing (startPublishing(long) / stop()).
When a message defines a correlationId.location, the orchestrator
generates a unique correlation ID at publish time and injects it at the
specified location (header or payload JSON Pointer).
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncApiMockOrchestrator(AsyncApiSpec spec, MessagePublisher publisher) AsyncApiMockOrchestrator(AsyncApiSpec spec, MessagePublisher publisher, MessageExampleGenerator generator) Constructor for use with a custom generator (used by the control-plane implementation and tests). -
Method Summary
Modifier and TypeMethodDescriptionThe failure message from the most recent scheduled publish cycle, or null if the last cycle succeeded.voidPublish the generated example message for each message in each channel, threading any AsyncAPI bindings (MQTT qos/retain, Kafka key) and correlation IDs asPublishOptions.voidstartPublishing(long intervalMillis) Start periodic publishing at the given interval.voidstop()Stop periodic publishing, waiting for an in-flight publish to finish.
-
Constructor Details
-
AsyncApiMockOrchestrator
-
AsyncApiMockOrchestrator
public AsyncApiMockOrchestrator(AsyncApiSpec spec, MessagePublisher publisher, MessageExampleGenerator generator) Constructor for use with a custom generator (used by the control-plane implementation and tests).
-
-
Method Details
-
publishAll
public void publishAll()Publish the generated example message for each message in each channel, threading any AsyncAPI bindings (MQTT qos/retain, Kafka key) and correlation IDs asPublishOptions.Multi-message channels (v3 multiple
messages, v2oneOf) result in one publish call per message. Single-message channels behave identically to the previous single-publish behavior. -
startPublishing
public void startPublishing(long intervalMillis) Start periodic publishing at the given interval.- Parameters:
intervalMillis- the interval between publish cycles in milliseconds
-
getLastPublishFailure
The failure message from the most recent scheduled publish cycle, or null if the last cycle succeeded. Exposed so a stalled or failing mock can be diagnosed without reading the log. -
stop
public void stop()Stop periodic publishing, waiting for an in-flight publish to finish.Callers close the publishers immediately after this returns (see
resetInternal()), so returning while a scheduledpublishAllis still running would let that thread publish against a channel being closed underneath it. Shutting down gracefully and then awaiting termination closes that window:shutdown()cancels the periodic schedule (aScheduledThreadPoolExecutordrops periodic tasks on shutdown by default) while letting an already-running publish complete.Matches the shutdown shape already used by
KafkaMessageSubscriberandKafkaAvroMessageSubscriber: same 5s budget, fall back toshutdownNow()if the publish overruns it, and restore the interrupt flag rather than swallowing the interrupt.
-