Skip to content

JMS Bridge Extension Swiftlet

Overview

The JMS Bridge Extension Swiftlet enables message bridging between SwiftMQ and external JMS servers. It supports bidirectional transfer of messages between local SwiftMQ queues or topics and remote JMS destinations, using configurable bridging definitions. The Swiftlet manages connection setup, message flow, and operational monitoring for each bridge instance.

Features

JMS Server Bridge Management

The Swiftlet allows you to define multiple remote JMS servers as bridge endpoints. Each server definition includes connection credentials, retry intervals, and an object factory for creating JMS administered objects. The object factory is typically a JNDI-based implementation, but can be replaced with custom classes to suit proprietary JMS environments. Server bridges can be enabled or disabled dynamically, and the Swiftlet manages connection lifecycle, including automatic reconnection based on the configured retry interval.

Object Factory Abstraction

The bridge uses an object factory (implementing the ObjectFactory interface) to obtain JMS connection factories and destinations. The default is com.swiftmq.extension.jmsbridge.JNDIObjectFactory, which performs JNDI lookups using provided properties. Custom object factories can be supplied by specifying their class name and properties in the configuration. The factory must provide a no-argument constructor and implement methods for returning QueueConnectionFactory, TopicConnectionFactory, Queue, and Topic objects.

Connection Caching and Reuse

Connections to remote JMS servers are cached and reused for efficiency. The ConnectionCache manages both queue and topic connections, as well as their associated factories, using the supplied credentials and exception listeners. All connections are closed and resources released when a server bridge is destroyed.

Configuration Example:

<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="remoteJmsServer" enabled="true" retryinterval="30000">
      <objectfactory class="com.swiftmq.extension.jmsbridge.JNDIObjectFactory">
        <properties>
        </properties>
      </objectfactory>
      <bridgings>
        <!-- Bridging definitions here -->
      </bridgings>
    </server>
  </servers>
</swiftlet>

Flexible Bridging Definitions

Within each server bridge, you can define multiple bridging configurations that specify the direction and mapping between local and remote destinations. Each bridging can operate in either local_to_remote or remote_to_local mode, supporting both queues and topics. For topics, durable subscriptions are supported via the durablename and clientid properties. The bridging also allows you to control the persistence mode of transferred messages (persistent, nonpersistent, or as_source).

Direction Control

The direction property determines whether messages flow from SwiftMQ to the remote JMS server (local_to_remote) or from the remote server to SwiftMQ (remote_to_local). The bridge adapts its source and sink components accordingly, using the appropriate local and remote connection/session APIs.

Queue and Topic Support

Both queues and topics are supported as local and remote destinations. For topics, the bridge can create temporary or durable subscriptions as needed. Durable subscriptions require specifying a clientid and durablename.

Persistence Mode

The transferpersistence property controls whether messages are sent as persistent, nonpersistent, or retain their original delivery mode (as_source). This affects both local and remote message delivery semantics.

Configuration Example:

<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="remoteJmsServer" enabled="true">
      <objectfactory class="com.swiftmq.extension.jmsbridge.JNDIObjectFactory">
        <properties>
        </properties>
      </objectfactory>
      <bridgings>
        <bridging name="orders-bridge" direction="local_to_remote" localname="orders" localtype="queue" remotefactoryname="RemoteQCF" remotename="remoteOrders" remotetype="queue" transferpersistence="persistent"/>
        <bridging name="topic-bridge" direction="remote_to_local" localname="mytopic" localtype="topic" remotefactoryname="RemoteTCF" remotename="remoteTopic" remotetype="topic" durablename="myDurable" transferpersistence="as_source"/>
      </bridgings>
    </server>
  </servers>
</swiftlet>

Operational Monitoring and Usage Statistics

The Swiftlet maintains a usage section that tracks the operational status of each active server bridge and its bridgings. For each bridge, the connect time is recorded, and for each bridging, the last transfer time and the number of messages transferred are maintained. These statistics are periodically updated based on the configured collect-interval and are visible in the management interface.

Collect Interval

The collect-interval property on the Swiftlet entity determines how often usage statistics are updated. This interval can be changed at runtime, and the Swiftlet will adjust its collection timer accordingly.

Configuration Example:

<swiftlet name="xt$jmsbridge" collect-interval="5000"/>

Configuration Guide

Bridging a Local Queue to a Remote JMS Queue

Use this scenario to forward messages from a SwiftMQ queue to a remote JMS queue, for example to integrate with a legacy JMS application.

  1. Define a server bridge for the remote JMS server, specifying the JNDI object factory and connection properties.
  2. Add a bridging entry with direction set to local_to_remote, mapping the local queue to the remote queue.
  3. Enable the server bridge.
<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="remoteJmsServer" enabled="true">
      <objectfactory class="com.swiftmq.extension.jmsbridge.JNDIObjectFactory">
        <properties>
        </properties>
      </objectfactory>
      <bridgings>
        <bridging name="orders-bridge" direction="local_to_remote" localname="orders" localtype="queue" remotefactoryname="RemoteQCF" remotename="remoteOrders" remotetype="queue" transferpersistence="persistent"/>
      </bridgings>
    </server>
  </servers>
</swiftlet>

Bridging a Remote JMS Topic to a Local Durable Subscription

Use this scenario to consume messages from a remote JMS topic and deliver them to a local SwiftMQ topic, using a durable subscription.

  1. Define a server bridge for the remote JMS server, including necessary JNDI properties.
  2. Add a bridging entry with direction set to remote_to_local, mapping the remote topic to the local topic, and specify a durablename and clientid.
  3. Enable the server bridge.
<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="remoteJmsServer" enabled="true" clientid="myClientId">
      <objectfactory class="com.swiftmq.extension.jmsbridge.JNDIObjectFactory">
        <properties>
        </properties>
      </objectfactory>
      <bridgings>
        <bridging name="topic-bridge" direction="remote_to_local" localname="mytopic" localtype="topic" remotefactoryname="RemoteTCF" remotename="remoteTopic" remotetype="topic" durablename="myDurable" transferpersistence="as_source"/>
      </bridgings>
    </server>
  </servers>
</swiftlet>

Scheduler Jobs

Server Bridge

Description: Activates a Server Bridge

Configuration Reference

The top-level entity in routerconfig.xml is <swiftlet name="xt$jmsbridge">.

<swiftlet name="xt$jmsbridge"> Properties

These properties are attributes of the <swiftlet name="xt$jmsbridge"> entity.

Parameter Type Default Mandatory Reboot Required Description
collect-interval Long 10000 No No Collect Interval (ms) for the Usage Section
<swiftlet name="xt$jmsbridge" collect-interval="10000"/>

<servers> in <swiftlet name="xt$jmsbridge">

Server Definitions

Each <server> entry is identified by its name attribute (the Server).

Parameter Type Default Mandatory Reboot Required Description
enabled Boolean false No No Enables/Disables this Server
clientid String No No Client Id for durable Subscribers
username String No No Username
password String No No Password
retryinterval Long 60000 No No Retry Interval (ms) for Re-Connect
<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="..."/>
  </servers>
</swiftlet>

<bridgings> in <servers>

JMS Bridging Definitions

Each <bridging> entry is identified by its name attribute (the JMS Bridging).

Parameter Type Default Mandatory Reboot Required Description
direction String local_to_remote Yes No Bridging Direction (choices: local_to_remote, remote_to_local)
localname String Yes No Name of the local Destination
localtype String queue Yes No Type of the local Destination (choices: queue, topic)
remotefactoryname String Yes No Name of the remote Queue/TopicConnectionFactory
remotename String Yes No Name of the remote Destination
remotetype String Yes No Type of the remote Destination (choices: queue, topic)
durablename String No No Name of the durable Subscriber
transferpersistence String as_source Yes No Persistence Mode for Message Transfer (choices: persistent, nonpersistent, as_source)
<swiftlet name="xt$jmsbridge">
  <servers>
    <server name="...">
      <bridgings>
        <bridging name="..." direction="..." localname="..." localtype="..." remotefactoryname="..." remotename="..." remotetype="..." transferpersistence="..."/>
      </bridgings>
    </server>
  </servers>
</swiftlet>

<objectfactory> in <servers>

Object Factory Definition

Parameter Type Default Mandatory Reboot Required Description
class String com.swiftmq.extension.jmsbridge.JNDIObjectFactory Yes No Object Factory Class