Chapter 9. Configuring Connection Factories

By default, the JBoss EAP messaging-activemq subsystem provides the InVmConnectionFactory and RemoteConnectionFactory connection factories, as well as the activemq-ra pooled connection factory.

Basic Connection Factories

InVmConnectionFactory references an in-vm-connector and can be used to send and receive messages when both the client and server are running in the same JVM. RemoteConnectionFactory references an http-connector and can be used to send and receive messages over HTTP when the client and server are running in different JVMs.

<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
  <server name="default">
    ...
    <connection-factory name="InVmConnectionFactory" connectors="in-vm" entries="java:/ConnectionFactory"/>
    <connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/>
    ...
  </server>
</subsystem>

For more information on the different types of connectors, see the Acceptors and Connectors section.

Add a Connection Factory

You can add a new connection factory using the following management CLI command. When adding a connection factory, you must provide the connectors and the JNDI entries.

/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:add(entries=[java:/MyConnectionFactory],connectors=[in-vm])

Configure a Connection Factory

You can update a connection factory’s settings using the management CLI.

/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:write-attribute(name=thread-pool-max-size,value=40)

For information on the available attributes for a connection factory, see Connection Factory Attributes.

Remove a Connection Factory

You can remove a connection factory using the management CLI.

/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:remove

Pooled Connection Factories

The JBoss EAP messaging-activemq subsystem provides a pooled connection factory that allows you to configure the inbound and outbound connectors of the integrated ActiveMQ Artemis resource adapter. For more information on configuring a pooled-connection-factory to connect to a remote ActiveMQ Artemis server, see Using the Integrated Resource Adapter for Remote Connections.

<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
  <server name="default">
    ...
    <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
  </server>
</subsystem>

There are several unique characteristics of a pooled connection factory:

  • It is only available to local clients, though it can be configured to point to a remote server. For more information on connecting to a remote ActiveMQ Artemis server, see Using the Integrated Artemis Resource Adapter for Remote Connections.
  • It should only be used to send messages when looked up in JNDI or injected.
  • It can be configured to use security credentials, which is useful if it is pointing to a secured remote server.
  • Resources acquired from it will be automatically enlisted in any ongoing JTA transactions.

Add a Pooled Connection Factory

You can add a new pooled connection factory using the following management CLI command. When adding a connection factory, you must provide the connectors and the JNDI entries.

/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledConnectionFactory:add(entries=[java:/MyPooledConnectionFactory],connectors=[in-vm])

Configure a Pooled Connection Factory

You can update a pooled connection factory’s settings using the management CLI.

/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledConnectionFactory:write-attribute(name=max-retry-interval,value=3000)

For information on the available attributes for a pooled connection factory, see Pooled Connection Factory Attributes.

You can disable the recording of enlistment traces for this pooled connection factory using the management CLI by setting the enlistment-trace attribute to false.

/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledConnectionFactory:write-attribute(name=enlistment-trace,value=false)
Warning

Disabling the enlistment trace will make tracking down errors during transaction enlistment more difficult.

You can also configure the managed connection pool implementation used by the pooled connection factory. For more information, see the Configure Managed Connection Pools section of the JBoss EAP Configuration Guide.

Remove a Pooled Connection Factory

You can remove a pooled connection factory using the management CLI.

/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledConnectionFactory:remove