Chapter 12. Configuring connection factories
By default, the JBoss EAP messaging-activemq subsystem provides the InVmConnectionFactory and RemoteConnectionFactory. You can also define additional connection factories or pooled connection factories, whether connecting to the embedded broker or to a remote ActiveMQ Artemis broker.
- Basic connection factories
-
InVmConnectionFactoryreferences anin-vm-connectorand can be used only when an embedded broker is present and both the client and server run 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 run in different JVMs. This factory can be defined even when no embedded broker is present, allowing applications to connect directly to a remote ActiveMQ Artemis server.
<subsystem xmlns="urn:jboss:domain:messaging-activemq:17.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 configurations that connect only to a remote broker (no embedded broker), connection factories are defined directly under the messaging-activemq subsystem, without the server=default element:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:17.0">
<connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:/RemoteCF"/>
</subsystem>
For more information about connector types, see the Acceptors and Connectors section.
- Add a connection factory
-
When adding a connection factory, you must provide the
connectorsand the JNDIentries.
With an embedded broker:
/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:add(entries=[java:/MyConnectionFactory],connectors=[in-vm])
With no embedded broker (remote‑only):
/subsystem=messaging-activemq/connection-factory=MyConnectionFactory:add(entries=[java:/MyConnectionFactory],connectors=[http-connector])
- Configure a connection factory
/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:write-attribute(name=thread-pool-max-size,value=40)
For a remote‑only configuration:
/subsystem=messaging-activemq/connection-factory=MyConnectionFactory:write-attribute(name=thread-pool-max-size,value=40)
- Remove a connection factory
/subsystem=messaging-activemq/server=default/connection-factory=MyConnectionFactory:remove
Remote‑only:
/subsystem=messaging-activemq/connection-factory=MyConnectionFactory:remove
- Pooled connection factories
-
The JBoss EAP
messaging-activemqsubsystem provides a pooled connection factory that configures the inbound and outbound connectors of the integrated ActiveMQ Artemis resource adapter. A pooled connection factory can be defined whether you are connecting to the embedded broker or to a remote broker.
subsystem xmlns="urn:jboss:domain:messaging-activemq:17.0">
...
<server name="default">
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
</server>
</subsystem>
For remote‑only configurations, the pooled connection factory is defined without server=default:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:17.0">
...
<server name="default">
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="http-connector" transaction="xa"/>
</server>
</subsystem>
Unique characteristics of a pooled connection factory:
- It is available only to local clients, though it can point to a remote server.
- It should only be used to send messages when looked up in JNDI or injected.
- It can be configured with security credentials, useful for secured remote servers.
Resources acquired from it can be automatically enlisted in any ongoing Jakarta Transactions transaction.
- Add a pooled connection factory
- Embedded broker:
/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledCF:add(entries=[java:/MyPooledCF],connectors=[in-vm])
Remote‑only:
/subsystem=messaging-activemq/pooled-connection-factory=MyPooledCF:add(entries=[java:/MyPooledCF],connectors=[http-connector])
- Configure a pooled connection factory
/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledCF:write-attribute(name=max-retry-interval,value=3000)
Remote-only:
/subsystem=messaging-activemq/pooled-connection-factory=MyPooledCF:write-attribute(name=max-retry-interval,value=3000)
- Remove a pooled connection factory
- Embedded broker:
/subsystem=messaging-activemq/server=default/pooled-connection-factory=MyPooledConnectionFactory:remove
Remote‑only:
/subsystem=messaging-activemq/pooled-connection-factory=MyPooledConnectionFactory:remove