org.apache.activemq.artemis.api.core.client

## Class ActiveMQClient

- java.lang.Object
- - org.apache.activemq.artemis.api.core.client.ActiveMQClient

-     public final class ActiveMQClient
      extends Object

  Utility class for creating ActiveMQ Artemis `ClientSessionFactory` objects.

  Once a `ClientSessionFactory` has been created, it can be further configured using its setter methods before creating the sessions. Once a session is created, the factory can no longer be modified (its setter methods will throw a `IllegalStateException`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_ACK_BATCH_SIZE`
    `static boolean` | `DEFAULT_AUTO_GROUP`
    `static boolean` | `DEFAULT_BLOCK_ON_ACKNOWLEDGE`
    `static boolean` | `DEFAULT_BLOCK_ON_DURABLE_SEND`
    `static boolean` | `DEFAULT_BLOCK_ON_NON_DURABLE_SEND`
    `static boolean` | `DEFAULT_CACHE_LARGE_MESSAGE_CLIENT`
    `static long` | `DEFAULT_CALL_FAILOVER_TIMEOUT`
    `static long` | `DEFAULT_CALL_TIMEOUT`
    `static long` | `DEFAULT_CLIENT_FAILURE_CHECK_PERIOD`
    `static long` | `DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM`
    `static boolean` | `DEFAULT_COMPRESS_LARGE_MESSAGES`
    `static int` | `DEFAULT_CONFIRMATION_WINDOW_SIZE`
    `static String` | `DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME`
    `static long` | `DEFAULT_CONNECTION_TTL`
    `static long` | `DEFAULT_CONNECTION_TTL_INVM`
    `static int` | `DEFAULT_CONSUMER_MAX_RATE`
    `static int` | `DEFAULT_CONSUMER_WINDOW_SIZE`
    `static String` | `DEFAULT_CORE_PROTOCOL`
    `static long` | `DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT`
    `static int` | `DEFAULT_DISCOVERY_PORT`
    `static long` | `DEFAULT_DISCOVERY_REFRESH_TIMEOUT`
    `static boolean` | `DEFAULT_FAILOVER_ON_INITIAL_CONNECTION`
    `static int` | `DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE`
    `static boolean` | `DEFAULT_HA`
    `static int` | `DEFAULT_INITIAL_MESSAGE_PACKET_SIZE`
    `static boolean` | `DEFAULT_IS_HA`
    `static long` | `DEFAULT_MAX_RETRY_INTERVAL`
    `static int` | `DEFAULT_MIN_LARGE_MESSAGE_SIZE`
    `static boolean` | `DEFAULT_PRE_ACKNOWLEDGE`
    `static int` | `DEFAULT_PRODUCER_MAX_RATE`
    `static int` | `DEFAULT_PRODUCER_WINDOW_SIZE`
    `static int` | `DEFAULT_RECONNECT_ATTEMPTS`
    `static long` | `DEFAULT_RETRY_INTERVAL`
    `static double` | `DEFAULT_RETRY_INTERVAL_MULTIPLIER`
    `static int` | `DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE`
    `static int` | `DEFAULT_THREAD_POOL_MAX_SIZE`
    `static boolean` | `DEFAULT_USE_GLOBAL_POOLS`
    `static boolean` | `DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING`
    `static boolean` | `DEFAULT_XA`
    `static int` | `INITIAL_CONNECT_ATTEMPTS`
    `static String` | `SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY`
    `static String` | `THREAD_POOL_MAX_SIZE_PROPERTY_KEY`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearThreadPools()`
    `static void` | `clearThreadPools(long time, TimeUnit unit)`
    `static ServerLocator` | `createServerLocator(boolean ha, DiscoveryGroupConfiguration groupConfiguration)` Create a ServerLocator which creates session factories from a set of live servers, no HA backup information is propagated to the client The UDP address and port are used to listen for live servers in the cluster
    `static ServerLocator` | `createServerLocator(boolean ha, TransportConfiguration... transportConfigurations)` Create a ServerLocator which creates session factories using a static list of transportConfigurations, the ServerLocator is not updated automatically as the cluster topology changes, and no HA backup information is propagated to the client
    `static ServerLocator` | `createServerLocator(String url)` Creates an ActiveMQConnectionFactory;
    `static ServerLocator` | `createServerLocatorWithHA(DiscoveryGroupConfiguration groupConfiguration)` Create a ServerLocator which will receive cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.
    `static ServerLocator` | `createServerLocatorWithHA(TransportConfiguration... initialServers)` Create a ServerLocator which will receive cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.
    `static ServerLocator` | `createServerLocatorWithoutHA(DiscoveryGroupConfiguration groupConfiguration)` Create a ServerLocator which creates session factories from a set of live servers, no HA backup information is propagated to the client
    `static ServerLocator` | `createServerLocatorWithoutHA(TransportConfiguration... transportConfigurations)` Create a ServerLocator which creates session factories using a static list of transportConfigurations, the ServerLocator is not updated automatically as the cluster topology changes, and no HA backup information is propagated to the client
    `static ScheduledExecutorService` | `getGlobalScheduledThreadPool()`
    `static int` | `getGlobalScheduledThreadPoolSize()`
    `static ExecutorService` | `getGlobalThreadPool()`
    `static int` | `getGlobalThreadPoolSize()`
    `static void` | `initializeGlobalThreadPoolProperties()` Initializes the global thread pools properties from System properties.
    `static void` | `injectPools(ExecutorService globalThreadPool, ScheduledExecutorService scheduledThreadPool)` Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call.
    `static void` | `setGlobalThreadPoolProperties(int globalThreadMaxPoolSize, int globalScheduledThreadPoolSize)` Allows programmatical configuration of global thread pools properties.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME

          public static final String DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME

    - #### DEFAULT_CLIENT_FAILURE_CHECK_PERIOD

          public static final long DEFAULT_CLIENT_FAILURE_CHECK_PERIOD

    - #### DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM

          public static final long DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM

      See Also:
        Constant Field Values

    - #### DEFAULT_CONNECTION_TTL

          public static final long DEFAULT_CONNECTION_TTL

    - #### DEFAULT_CONNECTION_TTL_INVM

          public static final long DEFAULT_CONNECTION_TTL_INVM

      See Also:
        Constant Field Values

    - #### DEFAULT_MIN_LARGE_MESSAGE_SIZE

          public static final int DEFAULT_MIN_LARGE_MESSAGE_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_COMPRESS_LARGE_MESSAGES

          public static final boolean DEFAULT_COMPRESS_LARGE_MESSAGES

      See Also:
        Constant Field Values

    - #### DEFAULT_CONSUMER_WINDOW_SIZE

          public static final int DEFAULT_CONSUMER_WINDOW_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_CONSUMER_MAX_RATE

          public static final int DEFAULT_CONSUMER_MAX_RATE

      See Also:
        Constant Field Values

    - #### DEFAULT_CONFIRMATION_WINDOW_SIZE

          public static final int DEFAULT_CONFIRMATION_WINDOW_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_PRODUCER_WINDOW_SIZE

          public static final int DEFAULT_PRODUCER_WINDOW_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_PRODUCER_MAX_RATE

          public static final int DEFAULT_PRODUCER_MAX_RATE

      See Also:
        Constant Field Values

    - #### DEFAULT_BLOCK_ON_ACKNOWLEDGE

          public static final boolean DEFAULT_BLOCK_ON_ACKNOWLEDGE

      See Also:
        Constant Field Values

    - #### DEFAULT_BLOCK_ON_DURABLE_SEND

          public static final boolean DEFAULT_BLOCK_ON_DURABLE_SEND

      See Also:
        Constant Field Values

    - #### DEFAULT_BLOCK_ON_NON_DURABLE_SEND

          public static final boolean DEFAULT_BLOCK_ON_NON_DURABLE_SEND

      See Also:
        Constant Field Values

    - #### DEFAULT_AUTO_GROUP

          public static final boolean DEFAULT_AUTO_GROUP

      See Also:
        Constant Field Values

    - #### DEFAULT_CALL_TIMEOUT

          public static final long DEFAULT_CALL_TIMEOUT

      See Also:
        Constant Field Values

    - #### DEFAULT_CALL_FAILOVER_TIMEOUT

          public static final long DEFAULT_CALL_FAILOVER_TIMEOUT

      See Also:
        Constant Field Values

    - #### DEFAULT_ACK_BATCH_SIZE

          public static final int DEFAULT_ACK_BATCH_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_PRE_ACKNOWLEDGE

          public static final boolean DEFAULT_PRE_ACKNOWLEDGE

      See Also:
        Constant Field Values

    - #### DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT

          public static final long DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT

      See Also:
        Constant Field Values

    - #### DEFAULT_DISCOVERY_REFRESH_TIMEOUT

          public static final long DEFAULT_DISCOVERY_REFRESH_TIMEOUT

      See Also:
        Constant Field Values

    - #### DEFAULT_DISCOVERY_PORT

          public static final int DEFAULT_DISCOVERY_PORT

      See Also:
        Constant Field Values

    - #### DEFAULT_RETRY_INTERVAL

          public static final long DEFAULT_RETRY_INTERVAL

      See Also:
        Constant Field Values

    - #### DEFAULT_RETRY_INTERVAL_MULTIPLIER

          public static final double DEFAULT_RETRY_INTERVAL_MULTIPLIER

    - #### DEFAULT_MAX_RETRY_INTERVAL

          public static final long DEFAULT_MAX_RETRY_INTERVAL

    - #### DEFAULT_RECONNECT_ATTEMPTS

          public static final int DEFAULT_RECONNECT_ATTEMPTS

      See Also:
        Constant Field Values

    - #### INITIAL_CONNECT_ATTEMPTS

          public static final int INITIAL_CONNECT_ATTEMPTS

      See Also:
        Constant Field Values

    - #### DEFAULT_FAILOVER_ON_INITIAL_CONNECTION

          public static final boolean DEFAULT_FAILOVER_ON_INITIAL_CONNECTION

      See Also:
        Constant Field Values

    - #### DEFAULT_IS_HA

          public static final boolean DEFAULT_IS_HA

      See Also:
        Constant Field Values

    - #### DEFAULT_USE_GLOBAL_POOLS

          public static final boolean DEFAULT_USE_GLOBAL_POOLS

      See Also:
        Constant Field Values

    - #### DEFAULT_THREAD_POOL_MAX_SIZE

          public static final int DEFAULT_THREAD_POOL_MAX_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE

          public static final int DEFAULT_GLOBAL_THREAD_POOL_MAX_SIZE

    - #### DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE

          public static final int DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_CACHE_LARGE_MESSAGE_CLIENT

          public static final boolean DEFAULT_CACHE_LARGE_MESSAGE_CLIENT

      See Also:
        Constant Field Values

    - #### DEFAULT_INITIAL_MESSAGE_PACKET_SIZE

          public static final int DEFAULT_INITIAL_MESSAGE_PACKET_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_XA

          public static final boolean DEFAULT_XA

      See Also:
        Constant Field Values

    - #### DEFAULT_HA

          public static final boolean DEFAULT_HA

      See Also:
        Constant Field Values

    - #### DEFAULT_CORE_PROTOCOL

          public static final String DEFAULT_CORE_PROTOCOL

      See Also:
        Constant Field Values

    - #### DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING

          public static final boolean DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING

      See Also:
        Constant Field Values

    - #### THREAD_POOL_MAX_SIZE_PROPERTY_KEY

          public static final String THREAD_POOL_MAX_SIZE_PROPERTY_KEY

      See Also:
        Constant Field Values

    - #### SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY

          public static final String SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### clearThreadPools

          public static void clearThreadPools()

    - #### clearThreadPools

          public static void clearThreadPools(long time,
                                              TimeUnit unit)

    - #### injectPools

          public static void injectPools(ExecutorService globalThreadPool,
                                         ScheduledExecutorService scheduledThreadPool)

      Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call.

    - #### getGlobalThreadPool

          public static ExecutorService getGlobalThreadPool()

    - #### getGlobalScheduledThreadPool

          public static ScheduledExecutorService getGlobalScheduledThreadPool()

    - #### getGlobalThreadPoolSize

          public static int getGlobalThreadPoolSize()

    - #### getGlobalScheduledThreadPoolSize

          public static int getGlobalScheduledThreadPoolSize()

    - #### initializeGlobalThreadPoolProperties

          public static void initializeGlobalThreadPoolProperties()

      Initializes the global thread pools properties from System properties. This method will update the global thread pool configuration based on defined System properties (or defaults if they are not set). The System properties key names are as follow: ActiveMQClient.THREAD_POOL_MAX_SIZE_PROPERTY_KEY="activemq.artemis.client.global.thread.pool.max.size" ActiveMQClient.SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY="activemq.artemis.client.global.scheduled.thread.pool.core.size The min value for max thread pool size is 2. If the value is not -1, but lower than 2, it will be ignored and will default to 2. A value of -1 configures an unbounded thread pool. Note: If global thread pools have already been created, they will not be updated with these new values.

    - #### setGlobalThreadPoolProperties

          public static void setGlobalThreadPoolProperties(int globalThreadMaxPoolSize,
                                                           int globalScheduledThreadPoolSize)

      Allows programmatical configuration of global thread pools properties. This method will update the global thread pool configuration based on the provided values notifying all globalThreadPoolListeners. Note: If global thread pools have already been created, they will not be updated with these new values. The min value for globalThreadMaxPoolSize is 2. If the value is not -1, but lower than 2, it will be ignored and will default to 2. A value of -1 configures an unbounded thread pool.

    - #### createServerLocator

          public static ServerLocator createServerLocator(String url)
                                                   throws Exception

      Creates an ActiveMQConnectionFactory;
      Returns:
        the ActiveMQConnectionFactory
      Throws:
        `Exception`

    - #### createServerLocatorWithoutHA

          public static ServerLocator createServerLocatorWithoutHA(TransportConfiguration... transportConfigurations)

      Create a ServerLocator which creates session factories using a static list of transportConfigurations, the ServerLocator is not updated automatically as the cluster topology changes, and no HA backup information is propagated to the client
      Parameters:
        `transportConfigurations` -
      Returns:
        the ServerLocator

    - #### createServerLocator

          public static ServerLocator createServerLocator(boolean ha,
                                                          TransportConfiguration... transportConfigurations)

      Create a ServerLocator which creates session factories using a static list of transportConfigurations, the ServerLocator is not updated automatically as the cluster topology changes, and no HA backup information is propagated to the client
      Parameters:
        `ha` - The Locator will support topology updates and ha (this required the server to be clustered, otherwise the first connection will timeout)
        `transportConfigurations` -
      Returns:
        the ServerLocator

    - #### createServerLocatorWithoutHA

          public static ServerLocator createServerLocatorWithoutHA(DiscoveryGroupConfiguration groupConfiguration)

      Create a ServerLocator which creates session factories from a set of live servers, no HA backup information is propagated to the client

      The UDP address and port are used to listen for live servers in the cluster

      Parameters:
        `groupConfiguration` -
      Returns:
        the ServerLocator

    - #### createServerLocator

          public static ServerLocator createServerLocator(boolean ha,
                                                          DiscoveryGroupConfiguration groupConfiguration)

      Create a ServerLocator which creates session factories from a set of live servers, no HA backup information is propagated to the client The UDP address and port are used to listen for live servers in the cluster
      Parameters:
        `ha` - The Locator will support topology updates and ha (this required the server to be clustered, otherwise the first connection will timeout)
        `groupConfiguration` -
      Returns:
        the ServerLocator

    - #### createServerLocatorWithHA

          public static ServerLocator createServerLocatorWithHA(TransportConfiguration... initialServers)

      Create a ServerLocator which will receive cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.

      The initial list of servers supplied in this method is simply to make an initial connection to the cluster, once that connection is made, up to date cluster topology information is downloaded and automatically updated whenever the cluster topology changes.

      If the topology includes backup servers that information is also propagated to the client so that it can know which server to failover onto in case of live server failure.

      Parameters:
        `initialServers` - The initial set of servers used to make a connection to the cluster. Each one is tried in turn until a successful connection is made. Once a connection is made, the cluster topology is downloaded and the rest of the list is ignored.
      Returns:
        the ServerLocator

    - #### createServerLocatorWithHA

          public static ServerLocator createServerLocatorWithHA(DiscoveryGroupConfiguration groupConfiguration)

      Create a ServerLocator which will receive cluster topology updates from the cluster as servers leave or join and new backups are appointed or removed.

      The discoveryAddress and discoveryPort parameters in this method are used to listen for UDP broadcasts which contain connection information for members of the cluster. The broadcasted connection information is simply used to make an initial connection to the cluster, once that connection is made, up to date cluster topology information is downloaded and automatically updated whenever the cluster topology changes.

      If the topology includes backup servers that information is also propagated to the client so that it can know which server to failover onto in case of live server failure.

      Parameters:
        `groupConfiguration` -
      Returns:
        the ServerLocator

Copyright © 2018 The Apache Software Foundation. All rights reserved.