Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To connect to an external broker, the ActiveMQ embedded broker must be disabled and an ActiveMQ connection factory must be configured in the runtime systemConfig.xml. The following illustrates how disable the embedded broker and create a connection factory (ConnectionFactory1) that connects to the default ActiveMQ broker configuration:

Code Block
xml
xml

<jms>
   <activemq broker.disabled="true"/>
   <connection.factories>
      <connection.factory name="ConnectionFactory1" broker.url="tcp://localhost:61616" type="xa"/>
   </connection.factories>
</jms>

...

The connection factory can then be used by a JMS binding configuration in a composite as follows:

Code Block
xml
xml

<channel name="TestChannel">
   <binding.jms>
      <connectionFactory jndiName="ConnectionFactory1"/>
      <destination jndiName="TestTopic"/>
   </binding.jms>
</channel>

...

Default XA and non-XA connection factories can be setup in systemConfig.xml. If no connection factory is specified in a binding configuration, either the default XA or non-XA factory will be used depending on whether global or local transacted messaging is required for a particular operation. Below is an example of how to set up default ActiveMQ connection factories:

Code Block
xml
xml

<jms>
   <connection.factories>
      <connection.factory name="xaDefault" broker.url="vm://broker" type="xa"/>
      <connection.factory name="default" broker.url="vm://broker"/>
   </connection.factories>
</jms>

...

ActiveMQ connection factories are configured in the runtime systemConfig.xml using the in-process broker URL as follows:

Code Block
xml
xml

<jms>
   <connection.factories>
      <connection.factory name="TheFactory" broker.url="vm://broker" type="xa"/>
   </connection.factories>
</jms>

The connection factories can then be used in binding configurations as illustrated below:

Code Block
xml
xml

<component name="TheComponent">
   <implementation.java .../>
   <reference name="service">
      <binding.jms>
         <connectionFactory name="TheFactory"/>
         <destination name="ServiceQueue"/>
      </binding.jms>
   </reference>
</component>

...

The default configuration using by the embedded ActiveMQ broker may be overridden in systemConfig.xml to specify custom ActiveMQ network and transport connectors:

Code Block
xml
xml

<jms>
   <active.mq>
      <networkConnectors>
         <networkConnector uri="multicast://default"/>
      </networkConnectors>
      <transportConnectors>
         <transportConnector name="openwire" uri="tcp://localhost:61616"/>
      </transportConnectors>
   </active.mq>
</jms>

Configuring Connection

...

Factories

JMS connection factories are configured as resources in a composite. The following example demonstrates how this is done using XML:

Code Block
xml
languagexml

<jms>
   <connection.factory.templates><composite ...>       <connection 
	<f3:connection.factory name="TheTemplateDurableConnectionFactory" brokerbinding.urluri="vm://brokerdurable" typeclient.id="xaTestClient"/>
   </connection.factory.templates>
</jms>

Templates are specified on the JMS binding using the connectionFactory.template attribute on the binding.jms element:

Code Block
xmlxml

<component name="TheComponent">
   <implementation.java .../ username=".." password="..">
   <reference name="service">    <factory.properties>
  <binding.jms connectionFactory.template="TheTemplate>          <destination name="ServiceQueue"/><pool.size.min>1</pool.size.min>
        </bindingfactory.jms>properties>
    </reference>f3:connection.factory>
</component>

...

composite>

The factory.properties element contains a list of key/value properties that are specific to the JMS provider. Client ID is used for durable connections. ActiveMQ also support the type attribute with LOCAL or XA as values.

Configuring Connection Templates

Connection Templates are no longer supported as of Fabric3 2.5.0.

Binding.SCA

In addition, the ActiveMQ extension is also a binding.sca provider. This means components can be wired and connected to remote channels without configuring transports or physical endpoint information – basically as if they were components locally wired. The ActiveMQ extension will manage queue setup and connections transparently.

Connection factories can be configured for use with binding.sca in systemConfig.xml using the binding.sca element. Specifically, the xa.factory and factory attributes point to an XA and non-XA connection factory configuration. When binding.sca is use for a wire or remote channel either the XA or non-XA connection factory will be used. The following demonstrates how to configure the binding.sca connection factories:

Code Block
xml
xml

<jms>
   <connection.factories>
      <connection.factory name="xaFactory" broker.url="vm://broker" type="xa"/>
      <connection.factory name="nonXaFactory" broker.url="vm://broker" type="local"/>
   </connection.factories>

   <binding.sca xa.factory="xaFactory" factory= "nonXaFactory"/>
</jms>