ActiveMQ Source Connector for Confluent Cloud

The Kafka Connect ActiveMQ Source connector for Confluent Cloud connector reads messages from an ActiveMQ broker and writes the messages to an Apache Kafka® topic.

Features

The ActiveMQ Source connector includes the following features:

  • At least once delivery: The connector guarantees that records are delivered at least once to the Kafka topic.
  • Supports multiple tasks: The connector supports running one or more tasks. More tasks may improve performance.

For more information, see the Confluent Cloud connector limitations.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

Quick Start

Use this quick start to get up and running with the Confluent Cloud ActiveMQ source connector.

Prerequisites
  • Kafka cluster credentials. The following lists the different ways you can provide credentials.
    • Enter an existing service account resource ID.
    • Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.
    • Create a Confluent Cloud API key and secret. To create a key and secret, you can use confluent api-key create or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.

Using the Confluent Cloud Console

Step 1: Launch your Confluent Cloud cluster.

See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.

Step 2: Add a connector.

In the left navigation menu, click Data integration, and then click Connectors. If you already have connectors in your cluster, click + Add connector.

Step 3: Select your connector.

Click the ActiveMQ Source connector icon.

ActiveMQ Source Connector Icon

Step 4: Set up the connection.

Complete the following and click Continue.

Note

  • Make sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.
  1. Enter a connector name.
  2. Select the way you want to provide Kafka Cluster credentials. You can either select a service account resource ID or you can enter an API key and secret (or generate these in the Cloud Console).
  3. Select the Kafka topic name (or topic names) where you want data sent.
  4. Select an Output Kafka record value format. Options are AVRO, JSON, JSON_SR, and PROTOBUF. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf). See Environment Limitations for additional information.
  5. Add the ActiveMQ connection details. An ActiveMQ broker URL is similar to tcp://<remotehost>:61616. 61616 is the default ActiveMQ port.
  6. Add the ActiveMQ Session details.
    • Destination Name: The name of the JMS destination queue or topic the connector reads from.
    • Destination Type: The type of JMS destination. Select either queue or topic. This property defaults to topic.
    • Batch Size: The maximum number of records that the connector can read from the broker before it writes to Kafka. The connector task holds these records until they are acknowledged in Kafka which may affect memory usage. Acceptable values are 1 to 2048.
    • Unacknowledged Messages Limit: The maximum number of messages (per connector task) that can be received from a broker and written to Kafka before Kafka acknowledges that the messages have been received. This is the maximum number of JMS messages the task may duplicate in Kafka, if the connector task fails and is restarted. This value is typically set larger than Batch Size. If you enter a smaller value than the Batch Size value, the batch size is limited to the value used here.
    • Maximum time to wait…: The maximum amount of time in milliseconds (ms) for a task to build a batch. The batch is closed and sent to Kafka at the end of this time. The batch is sent to Kafka even if less messages are present than the specified batch size. This can help limit connector lag when the JMS queue or topic has a lower throughput. Defaults to 60000 ms (60 seconds).
    • Character Encoding: The character encoding to use while receiving the message. Defaults to UTF-8.
    • Durable Subscription: Whether the connector task subscription to the JMS topic is durable or not. Durable subscriptions require a Subscription Name. Defaults to false.
    • Subscription Name: The name of the JMS subscription. Required for durable subscriptions. This option is applicable only for JMS topics.
    • Message Selector: The JMS message selector that should be applied to messages in the destination.
  7. Enter the number of tasks in use by the connector. The connector supports multiple tasks. More tasks may improve performance.
  8. Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.

See the ActiveMQ Source configuration properties for property values and definitions.

Step 5: Launch the connector.

Verify the connection details by previewing the running configuration. Once you’ve validated that the properties are configured to your satisfaction, click Launch.

Tip

For information about previewing your connector output, see Connector Data Previews.

Step 6: Check the connector status.

The status for the connector should go from Provisioning to Running. It may take a few minutes.

Step 7: Check the Kafka topic.

After the connector is running, verify messages are populating your Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.

../_images/topology.png

Using the Confluent CLI

Complete the following steps to set up and run the connector using the Confluent CLI.

Note

  • Make sure you have all your prerequisites completed.
  • The example commands use Confluent CLI version 2. For more information see, Confluent CLI v2.

Step 1: List the available connectors.

Enter the following command to list available connectors:

confluent connect plugin list

Step 2: Show the required connector configuration properties.

Enter the following command to show the required connector properties:

confluent connect plugin describe <connector-catalog-name>

For example:

confluent connect plugin describe ActiveMQSource

Example output:

Following are the required configs:
connector.class: ActiveMQSource
name
kafka.auth.mode
kafka.api.key
kafka.api.secret
kafka.topic
output.data.format
activemq.url
activemq.username
activemq.password
jms.destination.name
tasks.max

Step 3: Create the connector configuration file.

Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.

{
  "connector.class": "ActiveMQSource",
  "name": "ActiveMQSource_0",
  "kafka.auth.mode": "KAFKA_API_KEY",
  "kafka.api.key": "<my-kafka-api-key>",
  "kafka.api.secret": "<my-kafka-api-secret>",
  "kafka.topic" : "topic_0",
  "output.data.format" : "AVRO",
  "activemq.url" : "tcp://<remotehost>:61616",
  "activemq.username" : "<username>",
  "activemq.password" : "<password>",
  "jms.destination.name" : "<JMS-queue-or-topic-name>",
  "tasks.max" : "1"
}

Note the following property definitions:

  • "name": Sets a name for your new connector.
  • "connector.class": Identifies the connector plugin name.
  • "kafka.auth.mode": Identifies the connector authentication mode you want to use. There are two options: SERVICE_ACCOUNT or KAFKA_API_KEY (the default). To use an API key and secret, specify the configuration properties kafka.api.key and kafka.api.secret, as shown in the example configuration (above). To use a service account, specify the Resource ID in the property kafka.service.account.id=<service-account-resource-ID>. To list the available service account resource IDs, use the following command:

    confluent iam service-account list
    

    For example:

    confluent iam service-account list
    
       Id     | Resource ID |       Name        |    Description
    +---------+-------------+-------------------+-------------------
       123456 | sa-l1r23m   | sa-1              | Service account 1
       789101 | sa-l4d56p   | sa-2              | Service account 2
    
  • "kafka.topic": The Kafka topic name (or comma-separated topic names) where you want data sent.

  • "output.data.format": Options are AVRO, JSON, JSON_SR, and PROTOBUF. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf). See Environment Limitations for additional information.

  • "activemq.url": The URL of the ActiveMQ broker. An ActiveMQ broker URL is similar to tcp://<remotehost>:61616.

  • "jms.destination.name": The name of the JMS destination queue or topic name to read from.

  • "tasks.max": Enter the number of tasks in use by the connector. The connector supports multiple tasks. More tasks may improve performance.

Single Message Transforms: See the Single Message Transforms (SMT) documentation for details about adding SMTs using the CLI.

See the ActiveMQ Source configuration properties for additional property values and definitions.

Step 4: Load the properties file and create the connector.

Enter the following command to load the configuration and start the connector:

confluent connect create --config <file-name>.json

For example:

confluent connect create --config activemq-source.json

Example output:

Created connector ActiveMQSource_0 lcc-ix4dl

Step 5: Check the connector status.

Enter the following command to check the connector status:

confluent connect plugin list

Example output:

ID          |    Name             | Status  |  Type
+-----------+---------------------+---------+-------+
lcc-ix4dl   | ActiveMQSource_0    | RUNNING | source

Step 6: Check the results on the broker.

After the connector is running, verify messages are populating your Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

Configuration Properties

The following connector configuration properties can be used with this connector.

activemq.url

The URL of the ActiveMQ broker.

  • Type: string
  • Importance: high
activemq.username

The username to use when connecting to ActiveMQ.

  • Type: string
  • Default: “”
  • Importance: high
activemq.password

The password to use when connecting to ActiveMQ.

  • Type: password
  • Default: [hidden]
  • Importance: high
jms.destination.name

The name of the JMS destination queue or topic name to read from.

  • Type: string
  • Importance: high
jms.destination.type

The type of JMS destination. This is either queue or topic.

  • Type: string
  • Default: queue
  • Valid Values: [queue, topic]
  • Importance: high
batch.size

The maximum number of records that a connector task may read from the JMS broker before writing to Kafka. The task holds these records until they are acknowledged in Kafka, which may affect memory usage.

  • Type: int
  • Valid Values: [1,…,2048]
  • Importance: medium
max.pending.messages

The maximum number of messages per task that can be received from JMS brokers and produced to Kafka before the task acknowledges the JMS session (messages). If the task fails and is restarted, this is the maximum number of JMS messages the task may duplicate in Kafka. This is typically set larger than batch.size. A smaller value than batch.size limits the size of the batches.

  • Type: int
  • Valid Values: [1,…]
  • Importance: medium
max.poll.duration

The maximum amount of time each task can build a batch. The batch is closed and sent to Kafka if not enough messages are read during the time allotted. This helps limit connector lag when the JMS queue/topic has a lower throughput.

  • Type: int
  • Default: 60000
  • Valid Values: [1,…]
  • Importance: low
character.encoding

The character encoding to use while receiving the message.

  • Type: string
  • Default: UTF-8
  • Valid Values: one of [ISO-8859-1, UTF-8, UTF-16, UTF-16LE, UTF-16BE, US-ASCII]
  • Importance: medium
jms.subscription.durable

Whether the subscription of the connector tasks to a JMS topic is durable or not.

  • Type: boolean
  • Default: false
  • Importance: medium
jms.subscription.name

The name of the JMS subscription. Supported only in durable subscriptions and JMS topics.

  • Type: string
  • Default: null
  • Importance: medium
jms.message.selector

The message selector that should be applied to messages in the destination.

  • Type: string
  • Default: “”
  • Importance: medium

Next Steps

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.

../_images/topology.png