tpf_publish_data: Publish data by using guaranteed delivery services

This function publishes data by using guaranteed delivery for JVM support.

Last updated

  • Changed in 2023.
  • Added in 2021.

Format

LIBS := CKFK

#include <tpf/tpfapi.h>

int tpf_publish_data(char * targetName, 
                     char * topic_data, 
                     char * key_data, 
                     unsigned short key_len, 
                     char * data, 
                     unsigned int data_len);
targetName
A pointer to an EBCDIC null-terminated string that identifies the target topic group that you want to use to temporarily store data in flight. The string can be a maximum of 48 bytes long.
topic_data
A pointer to an EBCDIC null-terminated string that identifies the topic that you want to publish to. The string can be a maximum of 127 bytes long.
key_data
A pointer to the key data, which accompanies the published data.
key_len
The length of the key data. Specify a maximum length of 65535 bytes.
data
A pointer to binary data to be published to the target topic group.
data_len
The length of the published data.

Normal return

Integer value of zero.

Error return

An integer value of -1 when the data could not be published. The following errno variables are set to indicate unique causes:
EAGAIN
The z/TPF system could not place the data on the target queue because of processing delays, a suspended queue, a full queue, an undefined queue, or a queue connection error.
EINVAL
The specified target group could not be located, was not initialized correctly, or could not be processed.
ENOMEM
The z/TPF system could not allocate enough ECB heap storage to process the request.

Programming considerations

  • To use this function, you must include the library that is specified in the prototype in your makefile.
  • For Kafka processing, the topic_data parameter specifies the target Kafka topic to use, and the key_data parameter is passed as the key data for Kafka, which is not required.
  • The connection parameters are defined in a properties file by using the name of the topic under the /sys/tpf_pbfiles/apps/kafka/ directory.  For example, /sys/tpf_pbfiles/apps/kafka/topicname.properties.

Examples

The following example publishes data to the kafkadf target.

#include <tpf/tpfapi.h>
.
.
char signal[100];
int length = sprintf((char*)signal,"seq:%lx:",signalseq);
char * inbuf;
char * outbuf;
size_t inlen, outlen;
inlen = length;
outlen = length;
inbuf = (char *)signal;
outbuf = (char *)signal;

tpf_convert_ebcdic_to_unicode(&inbuf, &inlen, &outbuf, &outlen, TPF_CCSID_IBM1047, TPF_CCSID_UTF8, 0);
int publish_rc = tpf_publish_data("kafkadf","testtopic",NULL,0,(char *)signal,(unsigned int)length);