ActiveMQ is the default JMS provider in Apache TomEE and OpenEJB.
Changing JMS implementation is as simple as using that implementation's Java EE Connector. The connector which will be a
.rar file should be bundled with the application in a
file. All JMS usage in that
.ear will favor the JMS ConnectionFactory and Topic and Queue implementations
that are configured in the
.rar file rather than ActiveMQ.
If the JMS implementation does not have a
.rar file, there are still some options for wiring in an alternate implementation.
If the JMS implementation does not have a Resource Archive (
.rar file) that defines a compliant Resource Adapter, the Generic Resource Adapter for JMS should work fine.
To use this Adapter in TomEE or OpenEJB you'll need to create a
service-jar.xml file and include that in a jar file and add it to the
Then you can declare
Queue and more via the
The one below should be considered boiler plate. Updating it to contain some useful default values for your JMS implementation would be good. These values can be overridden in the
Let's say that the following file lives in the jar at
<?xml version="1.0" encoding="UTF-8"?> <ServiceJar> <ServiceProvider id="genericra" service="Resource" types="GenericJMSRA" class-name="com.sun.genericra.GenericJMSRA"> UserName Password ProviderIntegrationMode ConnectionFactoryClassName QueueConnectionFactoryClassName TopicConnectionFactoryClassName XAConnectionFactoryClassName XAQueueConnectionFactoryClassName XATopicConnectionFactoryClassName UnifiedDestinationClassName TopicClassName QueueClassName SupportsXA ConnectionFactoryProperties JndiProperties CommonSetterMethodName RMPolicy LogLevel DeliveryType UseFirstXAForRedelivery </ServiceProvider> <ServiceProvider id="ConnectionFactory" service="Resource" types="javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, QueueConnectionFactory, TopicConnectionFactory" class-name="com.sun.genericra.outbound.ManagedJMSConnectionFactory"> ConnectionFactoryJndiName ClientId ConnectionValidationEnabled ResourceAdapter </ServiceProvider> <ServiceProvider id="Queue" service="Resource" types="javax.jms.Queue, Queue" class-name="com.sun.genericra.outbound.QueueProxy"> DestinationJndiName ResourceAdapter UserName Password JndiProperties QueueClassName </ServiceProvider> <ServiceProvider id="Topic" service="Resource" types="javax.jms.Topic, Topic" class-name="com.sun.genericra.outbound.TopicProxy"> DestinationJndiName ResourceAdapter UserName Password JndiProperties TopicClassName </ServiceProvider> </ServiceJar>
It is strongly recommended to not leave the values in the service-jar.xml file blank as shown above. It is
possible to setup several sets of defaults in a
service-jar.xml or via several
Once this file is packed in a jar and added to the
<openejb.home>/lib directory, you can
then declare and configure "instances" of these things in your
openejb.xml config file as follows:
<Resource id="My Generic Adapter" type="GenericJMSRA" provider="org.superbiz:genericra"> AdapterProperty1 PropertyValue1 AdapterProperty2 PropertyValue2 ... </Resource>
Or in properties like so:
myGenericAdapter = new://Resource?type=GenericJMSRA&provider=org.superbiz:genericra myGenericAdapter.AdapterProperty1 = PropertyValue1 myGenericAdapter.AdapterProperty2 = PropertyValue2
This is basically the same as all configuration in TomEE/OpenEJB, but with the addition that you must
provider attribute so the server knows where to look for the
service-jar.xml file that
defines the resource and all its defaults.
In this example:
You can use whatever prefix you like for the
provider id, though for obvious reasons we'd advise not using
org.apache.tomee in the prefix.
All edits are reviewed before going live, so feel free to do much more than fix typos or links. If you see a page that could benefit from an entire rewrite, we'd be thrilled to review it. Don't be surprised if we like it so much we ask you for help with other pages :)NOTICE: unless indicated otherwise on the pages in question, all editable content available from apache.org is presumed to be licensed under the Apache License (AL) version 2.0 and hence all submissions to apache.org treated as formal Contributions under the license terms.