Class AsyncApiControlPlaneImpl
java.lang.Object
org.mockserver.async.controlplane.AsyncApiControlPlaneImpl
- All Implemented Interfaces:
org.mockserver.async.AsyncApiControlPlane
public class AsyncApiControlPlaneImpl
extends Object
implements org.mockserver.async.AsyncApiControlPlane
Implementation of
AsyncApiControlPlane that lives in the mockserver-async
module and is registered into the core's AsyncApiControlPlaneRegistry
at server startup.
Handles:
- Loading AsyncAPI specs via the REST control-plane
- Creating publishers and subscribers for each channel
- Schema validation of generated and consumed messages
- Returning status including recorded messages
- Resetting all state on server reset
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a control-plane with noConfigurationinstance, falling back entirely to the staticConfigurationPropertiesstore for async broker defaults.AsyncApiControlPlaneImpl(org.mockserver.configuration.Configuration configuration) Create a control-plane bound to the server'sConfigurationinstance so that instance-set async broker defaults are honoured. -
Method Summary
Modifier and TypeMethodDescriptiongenerateHttpExpectations(String requestBody) com.fasterxml.jackson.databind.JsonNodeReplaces whatever is loaded.static voidRegister this implementation into the core registry, without aConfigurationinstance.static voidregisterIfAvailable(org.mockserver.configuration.Configuration configuration) Register this implementation into the core registry.voidreset()Takes the brokers out of the control plane and closes them on a daemon thread, waiting up toCLOSE_WAITfor that before returning; closes still running then finish in the background.com.fasterxml.jackson.databind.JsonNodestatus()
-
Constructor Details
-
AsyncApiControlPlaneImpl
public AsyncApiControlPlaneImpl()Create a control-plane with noConfigurationinstance, falling back entirely to the staticConfigurationPropertiesstore for async broker defaults. -
AsyncApiControlPlaneImpl
public AsyncApiControlPlaneImpl(org.mockserver.configuration.Configuration configuration) Create a control-plane bound to the server'sConfigurationinstance so that instance-set async broker defaults are honoured.- Parameters:
configuration- the server configuration, ornullto use only the static store
-
-
Method Details
-
registerIfAvailable
public static void registerIfAvailable()Register this implementation into the core registry, without aConfigurationinstance. PreferregisterIfAvailable(Configuration)so that instance-set configuration is honoured. -
registerIfAvailable
public static void registerIfAvailable(org.mockserver.configuration.Configuration configuration) Register this implementation into the core registry. Call at server startup (e.g. from MockServerLifeCycle or Main).- Parameters:
configuration- the server configuration, ornullto use only the static store
-
load
Replaces whatever is loaded. The brokers it replaces, and any an earlier reset or a stopped server left closing, close on daemon threads, and the load waits for them without holding the monitor, so a reset, stop, status or verify meanwhile is not held up: a broker still closing can share the new brokers' client ids (MQTT disconnects the older session of a client id). AfterEARLIER_CLOSE_WAITit logs a warning and connects anyway. A reset or stop while it waits cancels it.- Specified by:
loadin interfaceorg.mockserver.async.AsyncApiControlPlane
-
status
public com.fasterxml.jackson.databind.JsonNode status()- Specified by:
statusin interfaceorg.mockserver.async.AsyncApiControlPlane
-
verify
- Specified by:
verifyin interfaceorg.mockserver.async.AsyncApiControlPlane
-
generateHttpExpectations
- Specified by:
generateHttpExpectationsin interfaceorg.mockserver.async.AsyncApiControlPlane
-
reset
public void reset()Takes the brokers out of the control plane and closes them on a daemon thread, waiting up toCLOSE_WAITfor that before returning; closes still running then finish in the background. Serverstop()runs this: closing can log (the orchestrator and the broker clients do), console logging is synchronous, and a broker can be slow to close, so neither a blocked console nor a slow broker may holdstop(), orload/status/verifybehind the monitor.- Specified by:
resetin interfaceorg.mockserver.async.AsyncApiControlPlane
-