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

    Constructors
    Constructor
    Description
    Create a control-plane with no Configuration instance, falling back entirely to the static ConfigurationProperties store for async broker defaults.
    AsyncApiControlPlaneImpl(org.mockserver.configuration.Configuration configuration)
    Create a control-plane bound to the server's Configuration instance so that instance-set async broker defaults are honoured.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    com.fasterxml.jackson.databind.JsonNode
    load(String requestBody)
    Replaces whatever is loaded.
    static void
    Register this implementation into the core registry, without a Configuration instance.
    static void
    registerIfAvailable(org.mockserver.configuration.Configuration configuration)
    Register this implementation into the core registry.
    void
    Takes the brokers out of the control plane and closes them on a daemon thread, waiting up to CLOSE_WAIT for that before returning; closes still running then finish in the background.
    com.fasterxml.jackson.databind.JsonNode
     
    verify(String verificationJson)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AsyncApiControlPlaneImpl

      public AsyncApiControlPlaneImpl()
      Create a control-plane with no Configuration instance, falling back entirely to the static ConfigurationProperties store for async broker defaults.
    • AsyncApiControlPlaneImpl

      public AsyncApiControlPlaneImpl(org.mockserver.configuration.Configuration configuration)
      Create a control-plane bound to the server's Configuration instance so that instance-set async broker defaults are honoured.
      Parameters:
      configuration - the server configuration, or null to use only the static store
  • Method Details

    • registerIfAvailable

      public static void registerIfAvailable()
      Register this implementation into the core registry, without a Configuration instance. Prefer registerIfAvailable(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, or null to use only the static store
    • load

      public com.fasterxml.jackson.databind.JsonNode load(String requestBody)
      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). After EARLIER_CLOSE_WAIT it logs a warning and connects anyway. A reset or stop while it waits cancels it.
      Specified by:
      load in interface org.mockserver.async.AsyncApiControlPlane
    • status

      public com.fasterxml.jackson.databind.JsonNode status()
      Specified by:
      status in interface org.mockserver.async.AsyncApiControlPlane
    • verify

      public String verify(String verificationJson)
      Specified by:
      verify in interface org.mockserver.async.AsyncApiControlPlane
    • generateHttpExpectations

      public String generateHttpExpectations(String requestBody)
      Specified by:
      generateHttpExpectations in interface org.mockserver.async.AsyncApiControlPlane
    • reset

      public void reset()
      Takes the brokers out of the control plane and closes them on a daemon thread, waiting up to CLOSE_WAIT for that before returning; closes still running then finish in the background. Server stop() 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 hold stop(), or load/status/verify behind the monitor.
      Specified by:
      reset in interface org.mockserver.async.AsyncApiControlPlane