Skip to content

Hardening and scaling

This page collects what you need to run InfoConnect for Kafka in production: security hardening, secrets management, throughput tuning, error handling and monitoring.

Security hardening

  • TLS to IBM i. Set as400.secure.connection to true and provide the truststore info400new.truststore. See Truststore management and IBM i TLS connection configuration.
  • IBM i user authority. Use a dedicated IBM i user ID that is authorized only for the data queues, programs and files that the connector uses. See Prerequisites: IBM i.
  • No plain-text secrets. Do not keep the IBM i password or storage credentials in plain text in the connector configuration. Encrypt them and store them in a topic, use environment variables, or use an external secret store, as described below.
  • Secure Kafka access. If your Kafka cluster requires authentication, set security.protocol, sasl.mechanism and sasl.jaas.config, as shown in the commented lines of the connector samples.
  • License and truststore in a topic. Keep the license and the truststore in a compacted Kafka topic instead of on the file system of each worker. See Storing the license and truststore in a topic.

Encrypting secrets

Step 1: Download the Secret Manager

Download SecretManager-1.0.0.jar and place it in your working directory.

Step 2: Create the input file

The input.json file contains your secrets and the Kafka properties. Create the file:

nano input.json

Add your secrets to the secrets object, as in the following sample:

input.json
{
  /* add your secrets in "secrets" json object. Please refer some sample properties mentioned below*/
  "secrets": {
    "as400-user": "<ibm-i-user>",
    "as400-password": "<ibm-i-password>"
  },
  "kafka": {
    "bootstrap.servers": "localhost:9092"
    /*Below are optional (Required if security enabled) */
    // "security.protocol": "SASL_SSL",
    // "sasl.mechanism": "PLAIN/SCRAM",
    // "sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"<api-key>\" password=\"<api-secret>\";"
  }
}

Step 3: Create the topic

Create the topic that stores the secrets:

bin/kafka-topics.sh --create \
    --bootstrap-server <broker-address> \
    --topic <secrets-topic-name> \
    --partitions 1 \
    --replication-factor 3 \
    --config cleanup.policy=compact \
    --config retention.ms=-1

Step 4: Produce the secrets to the topic

Produce the secrets to the topic with SecretManager-1.0.0.jar:

java -jar /path/to/SecretManager/SecretManager-1.0.0.jar <encryption-key> <input-json-file-path> <output-json-file-path> <secrets-topic>

Sample command:

java -jar /home/appadmin/secrets/SecretManager-1.0.0.jar 12345678912345 input.json output.json secrets_topic

After the secrets are produced to the topic, the output.json file contains the encrypted values.

Step 5: Configure the secrets in the connector

Sample configuration:

{
    /*other properties are removed for brevity*/
    "as400.userId": "as400-user",
    "as400.password": "as400-password"
}

To use an external secret store such as HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, or Azure Key Vault, see the documentation of the respective secret management tool for the integration with Kafka Connect.

Using environment variables for secrets

  1. Add the EnvVarConfigProvider configuration provider. Add the following properties to your connect-distributed.properties file:

    config.providers=env
    config.providers.env.class=org.apache.kafka.common.config.provider.EnvVarConfigProvider
    

    Note

    The EnvVarConfigProvider class is available in kafka-clients 3.5.0.

  2. Set the environment variables on your Linux machine with one of the following methods.

    Method 1: export the variable directly.

    export AS400_PASSWORD="password"
    

    Method 2: add the export command to ~/.bash_profile or ~/.bashrc.

  3. Use the environment variables in the connector configuration:

    {
      "name": "AS400SourceConnector_CDCDQ1622",
      "config": {
        "tasks.max": "1",
        "connector.class": "com.infoviewsystems.kafka.connect.as400.core.AS400SourceConnector",
        "as400.password": "${env:AS400_PASSWORD}"
      }
    }
    

Scaling and performance

Setting What it changes Reference
as400.source.consumer.numbers Number of internal threads that poll the data queue in parallel. Default 4. Source configuration properties
as400.source.concurrency Number of concurrent executors for each consumer. Source configuration properties
as400.source.poll.interval, as400.source.dq.wait.time How often and how long the connector waits when the data queue is empty. Source configuration properties
as400.source.flush.percentage Fraction of the buffered records that is flushed in each poll cycle. Source configuration properties
as400.max.connection, as400.prestart.count.dq, as400.prestart.count.command Size of the IBM i connection pool and the number of pre-started connections. Connection (Optional)
source.multiTopic Routes messages from one data queue to a topic for each table. Routing messages to multiple topics
as400.threadsafe Marks a called program as thread safe. Program Call sink properties

For the sizing of Kafka Connect itself, see the Kafka Connect prerequisites.

Error handling and recovery

  • Connection retries. The connector retries the IBM i connection as400.connection.retry times, as400.reconnection.period apart, before it reports the error to Kafka Connect. See Connection.
  • Dead letter queue. The sink connectors support the standard Kafka Connect dead letter queue properties (errors.tolerance, errors.deadletterqueue.topic.name). See the data queue sink samples.
  • Program call errors. Set fail.fast.on.program.call.exception to false to move failed records to the dead letter queue instead of stopping the connector. max.retries and retry.backoff.ms control the retries. See Program Call sink properties.
  • Format file errors. as400.source.format.action decides whether a message that fails because of a format file error is discarded or written back to the queue. See Source configuration properties.
  • Guaranteed delivery. With InfoCDC, the source connector can acknowledge each message through a response data queue or an acknowledgement program. See Source acknowledgement.

Monitoring and logging

  • Exception topic. The connector can log all critical exceptions to a dedicated topic (as400-error-log). To enable this, set log.exceptions=true. The default value is false, which means the connector does not log exceptions to the topic.
  • Connector status. The Kafka Connect REST API (GET /connectors/<name>/status) and the UI of your Kafka platform show whether the connector and its tasks run.
  • Kafka Connect logs. The connector writes to the Kafka Connect worker log. Use your standard log shipper to forward it to your log platform.