Module bus.extra

Class MQFactory

java.lang.Object
org.miaixz.bus.extra.mq.MQFactory

public class MQFactory extends Object
Factory class for creating and managing Message Queue (MQ) engine objects. This factory provides a mechanism to automatically detect and instantiate appropriate MQProvider implementations based on available JARs or explicit configuration.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • MQFactory

      public MQFactory()
  • Method Details

    • createEngine

      public static MQProvider createEngine(MQConfig config)
      Creates an MQProvider instance based on the provided MQConfig. This method attempts to automatically detect the correct MQ engine implementation from the classpath or uses a custom engine if specified in the configuration. It is recommended to manage the lifecycle of the returned engine, potentially as a singleton, as this method creates a new instance on each call.
      Parameters:
      config - The MQConfig containing connection details and optional custom engine class.
      Returns:
      A new MQProvider instance initialized with the given configuration.
      Throws:
      org.miaixz.bus.core.lang.exception.MQueueException - if no suitable MQ implementation is found or cannot be instantiated.