Copy to ClipboardCopied!Toggle word wrapToggle overflow
There are two different methods to register such services:
Publishing connection factories by using the jms:create Karaf console command. This is the configuration method.
Publishing connection factories by using methods such as Blueprint, OSGi Declarative Services (SCR) or just a BundleContext.registerService() API call. This method requires a dedicated OSGi bundle that contains the code and/or metadata. This is the deployment method.
proprietaryorg.ops4j.pax.jms.service.ConnectionFactoryFactory with the same purpose as standard OSGi JDBC org.osgi.service.jdbc.DataSourceFactory
proprietaryorg.ops4j.pax.jms.service.PooledConnectionFactoryFactory with the same purpose as proprietary pax-jdbc org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory
For the dedicated, broker-specific, org.ops4j.pax.jms.service.ConnectionFactoryFactory implementations, there are bundles such as:
mvn:org.ops4j.pax.jms/pax-jms-artemis/1.0.0
mvn:org.ops4j.pax.jms/pax-jms-ibmmq/1.0.0
mvn:org.ops4j.pax.jms/pax-jms-activemq/1.0.0
These bundles register broker-specific org.ops4j.pax.jms.service.ConnectionFactoryFactory services that can return JMS factories such as javax.jms.ConnectionFactory and javax.jms.XAConnectionFactory. For example:
The mvn:org.ops4j.pax.jms/pax-jms-config/1.0.0 bundle provides a Managed Service Factory that does three things:
Tracks org.ops4j.pax.jms.service.ConnectionFactoryFactory OSGi services to invoke its methods:
public ConnectionFactory createConnectionFactory(Map<String, Object> properties);
public XAConnectionFactory createXAConnectionFactory(Map<String, Object> properties);
public ConnectionFactory createConnectionFactory(Map<String, Object> properties);
public XAConnectionFactory createXAConnectionFactory(Map<String, Object> properties);
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Tracks org.ops4j.connectionfactoryfactory PIDs to collect properties that are required by the above methods. If you create a factory configuration by using any method available for Configuration Admin service, for example, by creating a ${karaf.etc}/org.ops4j.connectionfactory-artemis.cfg file, you can perform the final step to expose a broker-specific connection factory.
Tracks javax.jms.ConnectionFactory and javax.jms.XAConnectionFactory services to wrap them inside pooling JMS connection factories.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Note
If you specify additional Artemis configuration, specifically protocol=amqp, the QPID JMS library would be used instead of the Artemis JMS client. The amqp:// protocol has to be used then for jms.url property.
Test the connection.
You now have a broker-specific (no pooling yet) connection factory that you can inject where needed. For example, you can use Karaf commands from the jms feature:
This section shows how to connect to IBM MQ 8 and IBM MQ 9. Even though pax-jms-ibmmq installs the relevant pax-jms bundles, the IBM MQ driver is not installed due to licensing reasons.
Click the version that you want to install, for example, click IBM MQ 8.0 Client or IBM MQ 9.0 Client.
In the page that appears, at the bottom, in the table of download versions, click the version that you want.
In the next page, select the latest version that has the suffix IBM-MQ-Install-Java-All. For example, download 8.0.0.10-WS-MQ-Install-Java-All or 9.0.0.4-IBM-MQ-Install-Java-All.
Extract the content of the downloaded JAR file.
Execute the bundle:install command. For example, if you extracted the content into your /home/Downloads directory, you would enter a command such as the following:
The Fuse distribution contains the quickstarts/camel/camel-jms example, which you can build and install as an OSGi bundle. This bundle contains a Blueprint XML definition of a Camel route that sends messages to an JBoss A-MQ 6.3 JMS queue. The procedure for creating a connection factory for JBoss A-MQ 6.3 broker is as follows.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The JBoss A-MQ 6.3 connection factory is configured to connect to a broker listening at tcp://localhost:61616. By default JBoss A-MQ uses the IP port value 61616. The connection factory is also configured to use the userName/password credentials, admin/admin. Make sure that this user is enable in your broker cofiguration (or you can customize these settings here to match your broker configuration).
Save the camel-context.xml file.
Build the camel-jms quickstart:
cd camel/camel-jms
mvn install
$ cd camel/camel-jms
$ mvn install
Copy to ClipboardCopied!Toggle word wrapToggle overflow
After the quickstart is successfully installed, navigate to $FUSE_HOME/ directoy and run the following command to start the Fuse on Apache Karaf server:
./bin/fuse
$ ./bin/fuse
Copy to ClipboardCopied!Toggle word wrapToggle overflow
On the Fuse on Apache Karaf instance install activemq-client feature and camel-jms feature:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Where replace {$fuseversion} with the actual version of the Maven artifact that you just built (consult the camel-jms quickstart README file).
Start the JBoss A-MQ 6.3 broker (you need an installation of JBoss A-MQ 6.3 for this). Open another terminal window and navigate to JBOSS_AMQ_63_INSTALLDIR directory:
cd JBOSS_AMQ_63_INSTALLDIR
./bin/amq
$ cd JBOSS_AMQ_63_INSTALLDIR
$ ./bin/amq
Copy to ClipboardCopied!Toggle word wrapToggle overflow
As soon as the Camel routes have started, you can see a directory work/jms/input in your Fuse installation. Copy the files you find in this quickstart’s src/main/data directory to the newly created work/jms/input directory.
Wait a few moments and you will find the same files organized by country under the work/jms/output directory:
order1.xml, order2.xml and order4.xml in work/jms/output/others
order3.xml and order5.xml in work/jms/output/us
order6.xml in work/jms/output/fr
order1.xml, order2.xml and order4.xml in work/jms/output/others
order3.xml and order5.xml in work/jms/output/us
order6.xml in work/jms/output/fr
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Use log:display to check out the business logging:
Receiving order order1.xml
Sending order order1.xml to another country
Done processing order1.xml
Receiving order order1.xml
Sending order order1.xml to another country
Done processing order1.xml
Copy to ClipboardCopied!Toggle word wrapToggle overflow
If protocol=amqp, properties are passed to the org.apache.qpid.jms.util.PropertyUtil.setProperties() method to configure the org.apache.qpid.jms.JmsConnectionFactory instance.
Otherwise, org.apache.activemq.artemis.utils.uri.BeanSupport.setData() is called for the org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory instance.
Apache Karaf provides the jms feature, which includes shell commands in the jms:* scope. You already saw some examples of using these commands to check the manually configured connection factories. There are also commands that hide the need to create Configuration Admin configurations.
Starting with a fresh instance of Fuse, you can register a broker-specific connection factory. The following listing shows install of the jms feature from Karaf and installation of pax-jms-artemis from pax-jms:
karaf@root()> feature:install jms pax-jms-artemis
karaf@root()> jms:connectionfactories
JMS Connection Factory
──────────────────────
karaf@root()> service:list javax.jms.ConnectionFactory # should be empty
karaf@root()> service:list org.ops4j.pax.jms.service.ConnectionFactoryFactory
[org.ops4j.pax.jms.service.ConnectionFactoryFactory]
----------------------------------------------------
service.bundleid = 250
service.id = 326
service.scope = singleton
type = artemis
Provided by :
OPS4J Pax JMS Artemis Support (250)
karaf@root()> feature:install jms pax-jms-artemis
karaf@root()> jms:connectionfactories
JMS Connection Factory
──────────────────────
karaf@root()> service:list javax.jms.ConnectionFactory # should be empty
karaf@root()> service:list org.ops4j.pax.jms.service.ConnectionFactoryFactory
[org.ops4j.pax.jms.service.ConnectionFactoryFactory]
----------------------------------------------------
service.bundleid = 250
service.id = 326
service.scope = singleton
type = artemis
Provided by :
OPS4J Pax JMS Artemis Support (250)
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The following listing shows how to create and check an Artemis connection factory:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
As you can see, the org.ops4j.connectionfactory factory PID is created for you. However it is not automatically stored in ${karaf.etc}, which is possible with config:update. It is not possible to specify other properties, but you can add them later.
As with the pax-jdbc-config bundle, you can use Jasypt to encrypt properties.
If there is any org.jasypt.encryption.StringEncryptor service that is registered in OSGi with any alias service property, you can reference it in a connection factory factory PID and use encrypted passwords. Following is an example:
felix.fileinstall.filename = */etc/org.ops4j.connectionfactory-artemis.cfg
name = artemis
type = artemis
decryptor = my-jasypt-decryptor
url = tcp://localhost:61616
user = fuse
password = ENC(<encrypted-password>)
felix.fileinstall.filename = */etc/org.ops4j.connectionfactory-artemis.cfg
name = artemis
type = artemis
decryptor = my-jasypt-decryptor
url = tcp://localhost:61616
user = fuse
password = ENC(<encrypted-password>)
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The service filter used to find the decryptor service is (&(objectClass=org.jasypt.encryption.StringEncryptor)(alias=<alias>)), where <alias> is the value of the decryptor property from the connection factory configuration factory PID.
This section discusses JMS connection/session pooling options. There are fewer choices than there are for JDBC. The information is organized into the following topics:
So far, you have registered a broker-specific connection factory. Because a connection factory itself is a factory for connection factories, the org.ops4j.pax.jms.service.ConnectionFactoryFactory service may be treated as a meta factory. It should be able to produce two kinds of connection factories:
javax.jms.ConnectionFactory
javax.jms.XAConnectionFactory
The pax-jms-pool-* bundles work smoothly with the org.ops4j.pax.jms.service.ConnectionFactoryFactory service. These bundles provide implementations of org.ops4j.pax.jms.service.PooledConnectionFactoryFactory that can be used to create pooled connection factories by using a set of properties and the original org.ops4j.pax.jms.service.ConnectionFactoryFactory in a kind of wrapper way. For example:
The pax-jms-pool-narayana factory is called PooledJms(XA)PooledConnectionFactoryFactory because it is based on the pooled-jms library. It adds integration with the Narayana transaction manager for XA recovery.
The above bundles install only connection factory factories. The bundles to not install the connection factories themselves. Consequently, something is needed that calls the javax.jms.ConnectionFactory org.ops4j.pax.jms.service.PooledConnectionFactoryFactory.create() method.
An understanding of how to use the pax-jms-pool-pooledjms bundle helps you use not only the pax-jms-pool-pooledjms bundle, but also the pax-jms-pool-narayna bundle, which does almost everything as pax-jms-pool-pooledjms.
Instances of org.ops4j.pax.jms.service.PooledConnectionFactoryFactory that are registered by one of pax-jms-pool-* bundles.
If a factory configuration contains a pool property, the ultimate connection factory registered by the pax-jms-config bundle is the broker-specific connection factory. If pool=pooledjms then the connection factory is wrapped inside one of the following:
Besides the pool property (and the Boolean xa property, which selects one of non-xa/xa connection factories), the org.ops4j.connectionfactoryfactory PID may contain properties that are prefixed with pool..
For the pooled-jms library, these prefixed properties are used (after removing the prefix) to configure an instance of:
org.messaginghub.pooled.jms.JmsPoolConnectionFactory, or
The following listing is a realistic configuration of a pooled-jms pool (org.ops4j.connectionfactory-artemisfactory PID) that is using a convenient syntax with jms.-prefixed properties:
configuration for pax-jms-config to choose and configure specific org.ops4j.pax.jms.service.ConnectionFactoryFactory
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory specific coniguration
...
hints for pax-jms-config to use selected org.ops4j.pax.jms.service.PooledConnectionFactoryFactory
pooled-jms specific configuration of org.messaginghub.pooled.jms.JmsPoolConnectionFactory
...
# configuration for pax-jms-config to choose and configure specific org.ops4j.pax.jms.service.ConnectionFactoryFactory
name = jms/artemis
connectionFactoryType = ConnectionFactory
jms.url = tcp://localhost:61616
jms.user = fuse
jms.password = fuse
# org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory specific coniguration
jms.callTimeout = 12000
# ...
# hints for pax-jms-config to use selected org.ops4j.pax.jms.service.PooledConnectionFactoryFactory
pool = pooledjms
xa = false
# pooled-jms specific configuration of org.messaginghub.pooled.jms.JmsPoolConnectionFactory
pool.idleTimeout = 10
pool.maxConnections = 100
pool.blockIfSessionPoolIsFull = true
# ...
Copy to ClipboardCopied!Toggle word wrapToggle overflow
In the above configuration, pool and xa keys are hints (service filter properties) to choose one of the registered org.ops4j.pax.jms.service.PooledConnectionFactoryFactory services. In the case of the pooled-jms library it is:
The pax-jms-pool-narayna module does almost everything as pax-jms-pool-pooledjms. It installs the pooled-jms-specific org.ops4j.pax.jms.service.PooledConnectionFactoryFactory, both for XA and non-XA scenarios. The only difference is that in an XA scenario, there is an additional integration point. The org.jboss.tm.XAResourceRecovery OSGi service is registered to be picked up by com.arjuna.ats.arjuna.recovery.RecoveryManager.
The pax-jms-pool-transx module provides an implementation of org.ops4j.pax.jms.service.PooledConnectionFactoryFactory services that is based on the pax-transx-jms bundle. The pax-transx-jms bundle creates javax.jms.ConnectionFactory pools by using the org.ops4j.pax.transx.jms.ManagedConnectionFactoryBuilder facility. This is a JCA (Java™ Connector Architecture) solution that is discussed in Section 8.3, “About the pax-transx project”.
In the deployment method, javax.jms.ConnectionFactory services are registered directly by application code. Usually, this code is inside a Blueprint container. Blueprint XML may be part of an ordinary OSGi bundle, installable by using mvn: URI, and stored in a Maven repository (local or remote). It is easier to version-control such bundles as compared to Configuration Admin configurations.
The pax-jms-config version 1.0.0 bundle adds a deployment method for connection factory configuration. An application developer registers the javax.jms.(XA)ConnectionFactory service (usually by using Bluerpint XML) and specifies service properties. Then pax-jms-config detects the registered, broker-specific connection factory and (using service properties) wraps the service inside a generic, non broker-specific, connection pool.
Following are three deployment methods that use Blueprint XML.
In this method, the pax-jms-config bundle is not needed. Application code is responsible for registration of both broker-specific and generic connection pools.
<!--
Broker-specific, non-pooling, non-enlisting javax.jms.XAConnectionFactory
-->
<bean id="artemis" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
<argument value="tcp://localhost:61616" />
<property name="callTimeout" value="2000" />
<property name="initialConnectAttempts" value="3" />
</bean>
<!--
Fuse exports this service from fuse-pax-transx-tm-narayana bundle.
-->
<reference id="tm" interface="javax.transaction.TransactionManager" />
<!--
Non broker-specific, generic, pooling, enlisting javax.jms.ConnectionFactory
-->
<bean id="pool" class="org.messaginghub.pooled.jms.JmsPoolXAConnectionFactory">
<property name="connectionFactory" ref="artemis" />
<property name="transactionManager" ref="tm" />
<property name="maxConnections" value="10" />
<property name="idleTimeout" value="10000" />
</bean>
<!--
Expose connection factory for use by application code (such as Camel, Spring, ...)
-->
<service interface="javax.jms.ConnectionFactory" ref="pool">
<service-properties>
<!-- Giving connection factory a name using one of these properties makes identification easier in jms:connectionfactories: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!--<entry key="name" value="jms/artemis" />-->
<!-- Without any of the above, name will fall back to "service.id" -->
</service-properties>
</service>
<!--
Broker-specific, non-pooling, non-enlisting javax.jms.XAConnectionFactory
-->
<bean id="artemis" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
<argument value="tcp://localhost:61616" />
<property name="callTimeout" value="2000" />
<property name="initialConnectAttempts" value="3" />
</bean>
<!--
Fuse exports this service from fuse-pax-transx-tm-narayana bundle.
-->
<reference id="tm" interface="javax.transaction.TransactionManager" />
<!--
Non broker-specific, generic, pooling, enlisting javax.jms.ConnectionFactory
-->
<bean id="pool" class="org.messaginghub.pooled.jms.JmsPoolXAConnectionFactory">
<property name="connectionFactory" ref="artemis" />
<property name="transactionManager" ref="tm" />
<property name="maxConnections" value="10" />
<property name="idleTimeout" value="10000" />
</bean>
<!--
Expose connection factory for use by application code (such as Camel, Spring, ...)
-->
<service interface="javax.jms.ConnectionFactory" ref="pool">
<service-properties>
<!-- Giving connection factory a name using one of these properties makes identification easier in jms:connectionfactories: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!--<entry key="name" value="jms/artemis" />-->
<!-- Without any of the above, name will fall back to "service.id" -->
</service-properties>
</service>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Here are the shell commands that show how it should be used:
Copy to ClipboardCopied!Toggle word wrapToggle overflow
As shown in the above listing, the Blueprint bundle exports the javax.jms.ConnectionFactory service, which is a generic, non broker-specific, connection pool. The broker-specific javax.jms.XAConnectionFactory is not registered as an OSGi service, because Blueprint XML does not have an explicit <service ref="artemis"> declaration.
This method shows the use of pax-jms-config in a canonical way. This is a bit different than the method that was recommended for Fuse 6.x, where the requirement was to specify pooling configuration as service properties.
Here is the Blueprint XML example:
<!--
A broker-specific org.ops4j.pax.jms.service.ConnectionFactoryFactory that can create (XA)ConnectionFactory
using properties. It is registered by pax-jms-* bundles
-->
<reference id="connectionFactoryFactory"
interface="org.ops4j.pax.jms.service.ConnectionFactoryFactory"
filter="(type=artemis)" />
<!--
Non broker-specific org.ops4j.pax.jms.service.PooledConnectionFactoryFactory that can create
pooled connection factories with the help of org.ops4j.pax.jms.service.ConnectionFactoryFactory
For example, pax-jms-pool-pooledjms bundle registers org.ops4j.pax.jms.service.PooledConnectionFactoryFactory
with these properties:
- pool = pooledjms
- xa = true|false (both are registered)
-->
<reference id="pooledConnectionFactoryFactory"
interface="org.ops4j.pax.jms.service.PooledConnectionFactoryFactory"
filter="(&(pool=pooledjms)(xa=true))" />
<!--
When using XA connection factories, javax.transaction.TransactionManager service is not needed here.
It is used internally by xa-aware pooledConnectionFactoryFactory.
-->
<!--<reference id="tm" interface="javax.transaction.TransactionManager" />-->
<!--
Finally, use both factories to expose the pooled, xa-aware, connection factory.
-->
<bean id="pool" factory-ref="pooledConnectionFactoryFactory" factory-method="create">
<argument ref="connectionFactoryFactory" />
<argument>
<props>
<!--
Properties needed by artemis-specific org.ops4j.pax.jms.service.ConnectionFactoryFactory
-->
<prop key="jms.url" value="tcp://localhost:61616" />
<prop key="jms.callTimeout" value="2000" />
<prop key="jms.initialConnectAttempts" value="3" />
<!-- Properties needed by pooled-jms-specific org.ops4j.pax.jms.service.PooledConnectionFactoryFactory -->
<prop key="pool.maxConnections" value="10" />
<prop key="pool.idleTimeout" value="10000" />
</props>
</argument>
</bean>
<!--
Expose connection factory for use by application code (such as Camel, Spring, ...)
-->
<service interface="javax.jms.ConnectionFactory" ref="pool">
<service-properties>
<!-- Giving connection factory a name using one of these properties makes identification easier in jms:connectionfactories: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!--<entry key="name" value="jms/artemis" />-->
<!-- Without any of the above, name will fall back to "service.id" -->
</service-properties>
</service>
<!--
A broker-specific org.ops4j.pax.jms.service.ConnectionFactoryFactory that can create (XA)ConnectionFactory
using properties. It is registered by pax-jms-* bundles
-->
<reference id="connectionFactoryFactory"
interface="org.ops4j.pax.jms.service.ConnectionFactoryFactory"
filter="(type=artemis)" />
<!--
Non broker-specific org.ops4j.pax.jms.service.PooledConnectionFactoryFactory that can create
pooled connection factories with the help of org.ops4j.pax.jms.service.ConnectionFactoryFactory
For example, pax-jms-pool-pooledjms bundle registers org.ops4j.pax.jms.service.PooledConnectionFactoryFactory
with these properties:
- pool = pooledjms
- xa = true|false (both are registered)
-->
<reference id="pooledConnectionFactoryFactory"
interface="org.ops4j.pax.jms.service.PooledConnectionFactoryFactory"
filter="(&(pool=pooledjms)(xa=true))" />
<!--
When using XA connection factories, javax.transaction.TransactionManager service is not needed here.
It is used internally by xa-aware pooledConnectionFactoryFactory.
-->
<!--<reference id="tm" interface="javax.transaction.TransactionManager" />-->
<!--
Finally, use both factories to expose the pooled, xa-aware, connection factory.
-->
<bean id="pool" factory-ref="pooledConnectionFactoryFactory" factory-method="create">
<argument ref="connectionFactoryFactory" />
<argument>
<props>
<!--
Properties needed by artemis-specific org.ops4j.pax.jms.service.ConnectionFactoryFactory
-->
<prop key="jms.url" value="tcp://localhost:61616" />
<prop key="jms.callTimeout" value="2000" />
<prop key="jms.initialConnectAttempts" value="3" />
<!-- Properties needed by pooled-jms-specific org.ops4j.pax.jms.service.PooledConnectionFactoryFactory -->
<prop key="pool.maxConnections" value="10" />
<prop key="pool.idleTimeout" value="10000" />
</props>
</argument>
</bean>
<!--
Expose connection factory for use by application code (such as Camel, Spring, ...)
-->
<service interface="javax.jms.ConnectionFactory" ref="pool">
<service-properties>
<!-- Giving connection factory a name using one of these properties makes identification easier in jms:connectionfactories: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!--<entry key="name" value="jms/artemis" />-->
<!-- Without any of the above, name will fall back to "service.id" -->
</service-properties>
</service>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The previous example uses factory beans that create connection factories by using connection factory factories (…). There is no need for an explicit reference to the javax.transaction.TransactionManager service, as this is tracked internally by the XA-aware PooledConnectionFactoryFactory.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
As shown in the above listing, the Blueprint bundle exports the javax.jms.ConnectionFactory service, which is a generic, non broker-specific, connection pool. The broker-specific javax.jms.XAConnectionFactory is not registered as an OSGi service because Blueprint XML does not have an explicit <service ref="artemis"> declaration.
The pax-jms-config 1.0.0 bundle adds another way of wrapping broker-specific connection factories within pooling connection factories by using service properties. This method matches the way it used to work in Fuse 6.x.
Here is the Blueprint XML example:
<!--
Broker-specific, non-pooling, non-enlisting javax.jms.XAConnectionFactory
-->
<bean id="artemis" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
<argument value="tcp://localhost:61616" />
<property name="callTimeout" value="2000" />
<property name="initialConnectAttempts" value="3" />
</bean>
<!--
Expose broker-specific connection factory with service properties.
No need to expose pooling, enlisting, non broker-specific javax.jms.XAConnectionFactory. It will be registered
automatically by pax-jms-config with the same properties as this <service>, but with a higher service.ranking
-->
<service id="pool" ref="artemis" interface="javax.jms.XAConnectionFactory">
<service-properties>
<!-- "pool" key is needed for pax-jms-config to wrap broker-specific connection factory inside connection pool -->
<entry key="pool" value="pooledjms" />
<!-- <service>/@id attribute does not propagate, but name of the connection factory is required using one of: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!-- or: -->
<!--<entry key="name" value="jms/artemis" />-->
<!-- Other properties, that normally by e.g., pax-jms-pool-pooledjms -->
<entry key="pool.maxConnections" value="10" />
<entry key="pool.idleTimeout" value="10000" />
</service-properties>
</service>
<!--
Broker-specific, non-pooling, non-enlisting javax.jms.XAConnectionFactory
-->
<bean id="artemis" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
<argument value="tcp://localhost:61616" />
<property name="callTimeout" value="2000" />
<property name="initialConnectAttempts" value="3" />
</bean>
<!--
Expose broker-specific connection factory with service properties.
No need to expose pooling, enlisting, non broker-specific javax.jms.XAConnectionFactory. It will be registered
automatically by pax-jms-config with the same properties as this <service>, but with a higher service.ranking
-->
<service id="pool" ref="artemis" interface="javax.jms.XAConnectionFactory">
<service-properties>
<!-- "pool" key is needed for pax-jms-config to wrap broker-specific connection factory inside connection pool -->
<entry key="pool" value="pooledjms" />
<!-- <service>/@id attribute does not propagate, but name of the connection factory is required using one of: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!-- or: -->
<!--<entry key="name" value="jms/artemis" />-->
<!-- Other properties, that normally by e.g., pax-jms-pool-pooledjms -->
<entry key="pool.maxConnections" value="10" />
<entry key="pool.idleTimeout" value="10000" />
</service-properties>
</service>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
In the above example, you can see the manual register of only the broker-specific connection factory. The pool=pooledjms service property is a hint for the connection factory tracker that is managed by the pax-jms-config bundle. Connection factory services with this service property are wrapped within a pooling connection factory, in this example, pax-jms-pool-pooledjms.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
In the previous example, jms:connectionfactories shows only one service, because this command removes duplicate names. Two services were presented by jdbc:ds-list in the mixed deployment of data sources.
javax.jms.XAConnectionFactory is registered from the Blueprint bundle and it has the pool = pooledjms property declared.
javax.jms.ConnectionFactory is registered from the pax-jms-config bundle and:
It does not have the pool = pooledjms property. It was removed when registering the wrapper connection factory.
It has the service.ranking = 1000 property, so it is always the preferred version when, for example, looking for a connection factory by name.
It has the pax.jms.managed = true property, so it is not tried to be wrapped again.
It has the pax.jms.service.id.ref = 349 property, which indicates the original connection factory service that is wrapped inside the connection pool.