.. _ibmmq-sink-connector:

|kconnect-long| IBM MQ Sink Connector
=====================================

The IBM MQ Sink Connector is used to move messages from |ak| to an `IBM MQ <https://www.ibm.com/products/mq>`_ cluster.

.. note::
    If you are required to use JNDI to connect to IBM MQ,
    there is a general :ref:`JMS Sink Connector <jms-sink-connector>`
    available that uses a JNDI-based mechanism to connect to the JMS broker.

Prerequisites
-------------

The following are required to run the |kconnect-long| IBM MQ Sink Connector:

* Kafka Broker: |cp| 3.3.0 or above, or |ak| 0.11.0 or above
* Kafka Connect: |cp| 4.1.0 or above, or |ak| 1.1.0 or above (requires header support in Connect)
* `IBM MQ 8.0.0 <https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.pro.doc/q001010_.htm>`_
  or above, or `IBM MQ on Cloud <https://www.ibm.com/cloud/mq>`_ service
* IBM MQ Client Jar (See :ref:`Client Jars <ibmmq_client_jar>` section)
* Java 1.8

License
-------

.. include:: ../../includes/enterprise-license.rst

See :ref:`ibmmq_sink_connector_license_config` for license properties and :ref:`ibmmq_sink_license-topic-configuration` for information about the license topic.

Install IBM MQ Sink Connector
-----------------------------

.. include:: ../../includes/connector-install.rst

.. include:: ../../includes/connector-install-hub.rst

.. codewithvars:: bash

   confluent-hub install confluentinc/kafka-connect-ibmmq-sink:latest

.. include:: ../../includes/connector-install-version.rst

.. codewithvars:: bash

   confluent-hub install confluentinc/kafka-connect-ibmmq-sink:1.0.0-preview

.. important:: This connector does not include the IBM MQ client JAR. See the :ref:`ibmmq_client_jar` section for more details.

--------------------------
Install Connector Manually
--------------------------

`Download and extract the ZIP file <https://www.confluent.io/connector/kafka-connect-ibmmq-sink/#download>`_ for your
connector and then follow the manual connector installation :ref:`instructions <connect_install_connectors>`.

.. important:: This connector does not include the IBM MQ client JAR. See the :ref:`ibmmq_client_jar` section for more details.

.. _ibmmq_client_jar:

IBM MQ Client Library
---------------------

The |kconnect-long| IBM MQ connector does not come with the IBM MQ client library.

If you are running a multi-node |kconnect| cluster, the IBM MQ connector and IBM MQ client JAR
must be installed on **every** |kconnect| worker in the cluster. See below for details.

--------------------------------
Installing IBM MQ Client Library
--------------------------------

This connector relies on a provided ``com.ibm.mq.allclient`` client JAR distributed by IBM.
The connector **will not run** if you have not installed the JAR on each |kconnect| worker node.

The installation steps are:

#. Follow IBM's guide on `Obtaining the IBM MQ classes for JMS separately <https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q128170_.htm>`_ to download the IBM MQ client JAR.
#. The installation should have created a ``wmq/JavaSE`` directory. From this directory, copy **only** the ``com.ibm.mq.allclient.jar`` file into the ``share/java/kafka-connect-ibmmq-sink`` directory of your |cp| installation **on each worker node**.
#. Restart all of the |kconnect| worker nodes.

.. note::
    The ``share/java/kafka-connect-ibmmq-sink`` directory mentioned above is for |cp|.
    If you are using a different installation, find the location of the Confluent IBM MQ
    sink connector JAR files and place the IBM MQ client JAR file into the same directory.

.. include:: ../../includes/jms-message-formats.rst


Quick Start
-----------

This quick start uses the IBM MQ Sink Connector to consume records from |ak| and send them to an IBM MQ broker running in a Docker container.

#.  Start the IBM MQ broker.

    .. codewithvars:: bash

        docker run -d \
          -p 1414:1414 -p 9443:9443 \
          -e LICENSE=accept \
          ibmcom/mq:9.1.2.0

#.  Install the connector through the `Confluent Hub Client <https://docs.confluent.io/current/connect/managing/confluent-hub/client.html>`_.

    .. codewithvars:: bash

        # run from your Confluent Platform installation directory
        confluent-hub install confluentinc/kafka-connect-ibmmq-sink:latest

#.  Start |cp|.

    .. codewithvars:: bash

        |confluent_start|

#.  `Produce <https://docs.confluent.io/current/cli/command-reference/confluent-produce.html>`_ test data to the ``sink-messages`` topic in |ak|.

    .. codewithvars:: bash

        seq 10 | |confluent_produce| sink-messages

#.  Create a ``ibmmq-sink.json`` file with the following contents:

    .. codewithvars:: json

        {
          "name": "IbmMqSinkConnector",
          "config": {
            "connector.class": "io.confluent.connect.jms.IbmMqSinkConnector",
            "tasks.max": "1",
            "topics": "sink-messages",
            "mq.username": "app",
            "mq.channel": "DEV.APP.SVRCONN",
            "mq.hostname": "localhost",
            "mq.port": "1414",
            "mq.password": "",
            "mq.queue.manager": "mq",
            "mq.transport.type": "client",
            "jms.destination.type": "queue",
            "jms.destination.name": "DEV.QUEUE.1",
            "value.converter": "org.apache.kafka.connect.storage.StringConverter",
            "key.converter": "org.apache.kafka.connect.storage.StringConverter",
            "confluent.topic.replication.factor": "1",
            "confluent.topic.bootstrap.servers": "localhost:9091"
          }
        }

#.  Load the IBM MQ Sink Connector.

    .. include:: ../../../includes/confluent-local-consume-limit.rst

    .. codewithvars:: bash

       |confluent_load| mq|dash| -d ibmmq-sink.json

    .. important:: Don't use the :ref:`cli` in production environments.

#.  Confirm that the connector is in a ``RUNNING`` state.

    .. codewithvars:: bash

        |confluent_status| mq

#.  Navigate to the `IBM MQ Console <https://localhost:9443/ibmmq/console>`_ to confirm the messages were delivered to the ``DEV.QUEUE.1`` queue.

    .. tip:: The default credentials for the IBM MQ Console are ``admin``/``passw0rd``

Additional Documentation
------------------------

.. toctree::
  :maxdepth: 1

  connector_config
  changelog