Program Call sink connector
The Program Call sink connector calls an IBM i program (*PGM) or a service program procedure (*SRVPGM) for each message in a Kafka topic. It maps the message fields to the program parameters and can publish the output parameters to a topic.
| Connector class | com.infoviewsystems.kafka.connect.as400.core.AS400ProgramCallSinkConnector |
| Type | Sink |
| Typical use | Run IBM i business logic, such as creating an order, from an event in Kafka |
Configure the connection properties and the license together with the properties on this page.
Configuration properties
Configure the following Program Call sink connector properties.

| Parameter | Description | Mandatory | Default value | Configuration key |
|---|---|---|---|---|
| Program Name | IBM i program name. | Required | null | as400.program.name |
| Program Library | Program library name. | Required | null | as400.program.library |
| Program Parameters | List of definitions and value references of the program parameters. | Optional | null | as400.program.parameters |
| Procedure Name | Name of the procedure. | Optional | null | as400.procedure.name |
| Procedure Returns Value | Indicates whether the program procedure returns a value. | Optional | false | as400.procedure.returnsValue |
| Threadsafe | Indicates whether the program is thread safe. | Optional | false | as400.threadsafe |
| Sink Target Topic | Topic to which the program call output is sent. | Optional | null | sink.kafka.topic |
| Fail Fast Connector on Program Call Exception | Indicates whether the connector fails fast on a program call exception. When false, the connector suppresses program call errors and moves the affected records to the dead letter queue, if one is configured. |
Optional | true | fail.fast.on.program.call.exception |
| Maximum Retries | Number of retry attempts after a connection failure. | Optional | 3 | max.retries |
| Retry Backoff Milliseconds | Time between retries in ms. | Optional | 10000 | retry.backoff.ms |
Sample JSON for the Program Call sink connector
{
"name": "AS400ProgramCallSinkConnector",
"config": {
"connector.class": "com.infoviewsystems.kafka.connect.as400.core.AS400ProgramCallSinkConnector",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"topics": "CRTORDER_INPUT",
"as400.url": "your-ibm-i-host",
"as400.userId": "your-username",
"as400.password": "your-password",
"as400.secure.connection": "false",
"as400.license.protocol": "FILE",
"as400.license.path": "license-file-path",
"license.fileName": "as400-license.lic",
"as400.program.name": "program-name",
"as400.program.library": "KFKDEMOS",
"as400.program.libraryList": "comma-separated-list-of-libraries",
"as400.program.parameters": "{ \"params\": [ { \"parameterName\": \"sourceOrderId\", \"sourceFieldName\": \"$['sourceOrderId']\", \"dataType\": \"PACKED\", \"length\": 8, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"targetOrderId\", \"sourceFieldName\": \"$['targetOrderId']\", \"dataType\": \"PACKED\", \"length\": 8, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderAmt\", \"sourceFieldName\": \"$['orderAmt']\", \"dataType\": \"PACKED\", \"length\": 10, \"decimalPositions\": 2, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderStatus\", \"sourceFieldName\": \"$['orderStatus']\", \"dataType\": \"STRING\", \"length\": 10, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"numberOfLines\", \"sourceFieldName\": \"$['noOfItems']\", \"dataType\": \"PACKED\", \"length\": 4, \"decimalPositions\": 0, \"usage\": \"IN\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderLines\", \"sourceFieldName\": \"$['linesIn']\", \"dataType\": \"STRUCTURE\", \"length\": 0, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 10, \"dataStructureElements\": [ { \"parameterName\": \"itemNo\", \"sourceFieldName\": \"$['itemNo']\", \"dataType\": \"STRING\", \"length\": 10, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"quantity\", \"sourceFieldName\": \"$['quantity']\", \"dataType\": \"PACKED\", \"length\": 5, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"price\", \"sourceFieldName\": \"$['price']\", \"dataType\": \"PACKED\", \"length\": 10, \"decimalPositions\": 2, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] } ] } ] }",
"as400.threadsafe": "false",
"value.converter.schemas.enable": "false"
/*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>\";"
}
}
Calling programs and service programs
When you call a program (*PGM object), you typically do not need to specify a procedure name. Programs are generally standalone units of code that run without calling a specific procedure.
Service programs (*SRVPGM objects) are designed to be reused by multiple programs and can contain multiple exported procedures that you can call individually. To run a specific procedure of a service program, set as400.procedure.name to the exported name of that procedure.
Add the following properties to the sample above to call a procedure:
Defining the program parameters
The following definition describes the parameters of the IBM i program used in the sample:
d main pr extpgm('CRTORDER')
d srcOrder 8p 0
d trgtOrder 8p 0
d ordAmt 10p 2
d ordSts 10a
d nbrLines 4p 0
d linesIn likeds(linesInFmt) dim(10)
d linesInfmt DS Dim(10) qualified
d itemNo 10a
d qty 5p 0
d price 10p 2
The input message in the Kafka topic has the following structure:
{
"sourceOrderId": 11934700,
"targetOrderId": 11934700,
"orderAmt": 1000.00,
"orderStatus": "Activated",
"noOfItems": 2,
"linesIn": [
{
"itemNo": "111",
"quantity": 10,
"price": 10.00
},
{
"itemNo": "222",
"quantity": 90,
"price": 10.00
}
]
}
Transform the program parameters into the following as400.program.parameters structure:
Sample JSON for the program parameters
{
"params": [
{
"parameterName": "sourceOrderId",
"sourceFieldName": "$['sourceOrderId']",
"dataType": "PACKED",
"length": 8,
"decimalPositions": 0,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "targetOrderId",
"sourceFieldName": "$['targetOrderId']",
"dataType": "PACKED",
"length": 8,
"decimalPositions": 0,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "orderAmt",
"sourceFieldName": "$['orderAmt']",
"dataType": "PACKED",
"length": 10,
"decimalPositions": 2,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "orderStatus",
"sourceFieldName": "$['orderStatus']",
"dataType": "STRING",
"length": 10,
"decimalPositions": 0,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "numberOfLines",
"sourceFieldName": "$['noOfItems']",
"dataType": "PACKED",
"length": 4,
"decimalPositions": 0,
"usage": "IN",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "orderLines",
"sourceFieldName": "$['linesIn']",
"dataType": "STRUCTURE",
"length": 0,
"decimalPositions": 0,
"usage": "INOUT",
"count": 10,
"dataStructureElements": [
{
"parameterName": "itemNo",
"sourceFieldName": "$['itemNo']",
"dataType": "STRING",
"length": 10,
"decimalPositions": 0,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "quantity",
"sourceFieldName": "$['quantity']",
"dataType": "PACKED",
"length": 5,
"decimalPositions": 0,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
},
{
"parameterName": "price",
"sourceFieldName": "$['price']",
"dataType": "PACKED",
"length": 10,
"decimalPositions": 2,
"usage": "INOUT",
"count": 1,
"dataStructureElements": []
}
]
}
]
}
Note
The field names of the input structure must match the respective sourceFieldName values so that the connector can map the values.
Stringify this structure to use it as the value of as400.program.parameters:
{ \"params\": [ { \"parameterName\": \"sourceOrderId\", \"sourceFieldName\": \"$['sourceOrderId']\", \"dataType\": \"PACKED\", \"length\": 8, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"targetOrderId\", \"sourceFieldName\": \"$['targetOrderId']\", \"dataType\": \"PACKED\", \"length\": 8, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderAmt\", \"sourceFieldName\": \"$['orderAmt']\", \"dataType\": \"PACKED\", \"length\": 10, \"decimalPositions\": 2, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderStatus\", \"sourceFieldName\": \"$['orderStatus']\", \"dataType\": \"STRING\", \"length\": 10, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"numberOfLines\", \"sourceFieldName\": \"$['noOfItems']\", \"dataType\": \"PACKED\", \"length\": 4, \"decimalPositions\": 0, \"usage\": \"IN\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"orderLines\", \"sourceFieldName\": \"$['linesIn']\", \"dataType\": \"STRUCTURE\", \"length\": 0, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 10, \"dataStructureElements\": [ { \"parameterName\": \"itemNo\", \"sourceFieldName\": \"$['itemNo']\", \"dataType\": \"STRING\", \"length\": 10, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"quantity\", \"sourceFieldName\": \"$['quantity']\", \"dataType\": \"PACKED\", \"length\": 5, \"decimalPositions\": 0, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] }, { \"parameterName\": \"price\", \"sourceFieldName\": \"$['price']\", \"dataType\": \"PACKED\", \"length\": 10, \"decimalPositions\": 2, \"usage\": \"INOUT\", \"count\": 1, \"dataStructureElements\": [] } ] } ] }
The configuration for the Program Call sink connector is now ready to deploy.
Related pages
- Hardening and scaling: fail-fast behavior, retries and dead letter queue
- Screen Automation (RPA) sink: automate green screen navigation instead of calling a program