<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anthony Papageorgiou on Medium]]></title>
        <description><![CDATA[Stories by Anthony Papageorgiou on Medium]]></description>
        <link>https://medium.com/@anthonypapageorgiou?source=rss-20d023629711------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uig0vl1W1846dCUl7sik3w.jpeg</url>
            <title>Stories by Anthony Papageorgiou on Medium</title>
            <link>https://medium.com/@anthonypapageorgiou?source=rss-20d023629711------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:36:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anthonypapageorgiou/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From COBOL to Kafka]]></title>
            <link>https://medium.com/@anthonypapageorgiou/from-cobol-to-kafka-ac8cfb96f238?source=rss-20d023629711------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac8cfb96f238</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[events]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[mainframe]]></category>
            <category><![CDATA[cobol]]></category>
            <dc:creator><![CDATA[Anthony Papageorgiou]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 09:40:20 GMT</pubDate>
            <atom:updated>2024-08-15T09:40:20.856Z</atom:updated>
            <content:encoded><![CDATA[<h4>A quick guide to event producer patterns for z/OS applications</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VOnQpHOY_Xb381J9wOMH6Q.png" /></figure><h3>One of the most common questions I get asked from z/OS developers today is:</h3><blockquote>“How can I produce Kafka events from my applications?”</blockquote><p>Apache Kafka’s rise as an industry standard for event infrastructure means that we are seeing event driven patterns emerging as the crucial pillar of modernisation efforts. Events sit at a convergence of responsive application design, necessary extension of API integration, and real-time information sharing for hybrid applications and AI, so it’s only natural that the 70% of the world’s transactions which run on IBM mainframes would need to get in on the act. So how do you produce events from z/OS applications?</p><h3>Using a Kafka Client Library</h3><p>The first and most straightforward way to produce an event is to use a Kafka Client Library to directly produce events via a Kafka programming paradigm from inside your application. The Java Kafka Client Library has been a popular choice for developers on z/OS for a few years now, but the set of languages that can support this pattern on z/OS has been recently expand to COBOL, C and C++ with the release of the <a href="https://www.ibm.com/products/open-enterprise-sdk-kafka-apache">IBM Open Enterprise SDK for Apache Kafka</a></p><figure><img alt="A diagram showing z/OS applications using the Kafka Client to produce events directly to Kafka" src="https://cdn-images-1.medium.com/max/1024/1*iIZHHDZWpRrC-2jMp5yv_w.png" /><figcaption>Producing events from z/OS applications using a Kafka Client</figcaption></figure><p>Here’s a simple example of what that looks like in Java:</p><pre>ProducerRecord&lt;String, String&gt; record = new ProducerRecord&lt;&gt;(topic,message);<br>kafkaProducer.send(record);</pre><p>And in COBOL:</p><pre>      * Create PRODUCER<br>             SET KAFKA-TOPIC-REF   OF KAFKA-PRODUCE-IN<br>                             TO KAFKA-TOPIC-REF OF KAFKA-TOPIC-NEW-OUT<br>             MOVE PARTITION-VALUE TO PARTITION OF KAFKA-PRODUCE-IN<br>             MOVE MSGFLAGS-VALUE  TO MSGFLAGS  OF KAFKA-PRODUCE-IN<br>      * Convert Kafka payload into ASCII<br>             SET EBCDIC-DATA-PTR-31 OF EBCDIC-ASCII-CONV-IN<br>                  TO ADDRESS OF KAFKA-PAYLOAD<br>             MOVE FUNCTION EBCDIC-ASCII-CONV(<br>                     EBCDIC-DATA-PTR OF EBCDIC-ASCII-CONV-IN<br>                     ) TO<br>                     ASCII-DATA-PTR OF EBCDIC-ASCII-CONV-OUT<br>             SET PAYLOAD OF KAFKA-PRODUCE-IN<br>                          TO ASCII-DATA-PTR-31 OF EBCDIC-ASCII-CONV-OUT<br>             MOVE KAFKA-PAYLOAD-LEN TO PAYLOAD-LEN OF KAFKA-PRODUCE-IN<br>             SET PROD-KEY   OF KAFKA-PRODUCE-IN TO NULL<br>             MOVE 0         TO KEY-LEN OF KAFKA-PRODUCE-IN<br>             SET MSG-OPAQUE OF KAFKA-PRODUCE-IN TO NULL<br>             MOVE FUNCTION IXY-KAFKA-PRODUCE(<br>                             KAFKA-TOPIC-REF OF KAFKA-PRODUCE-IN<br>                             PARTITION       OF KAFKA-PRODUCE-IN<br>                             MSGFLAGS        OF KAFKA-PRODUCE-IN<br>                             PAYLOAD         OF KAFKA-PRODUCE-IN<br>                             PAYLOAD-LEN     OF KAFKA-PRODUCE-IN<br>                             PROD-KEY        OF KAFKA-PRODUCE-IN<br>                             KEY-LEN         OF KAFKA-PRODUCE-IN<br>                             MSG-OPAQUE      OF KAFKA-PRODUCE-IN<br>                           )<br>                           TO RETURN-STATUS   OF KAFKA-PRODUCE-OUT</pre><p>There’s a great article <a href="https://medium.com/@madhuba07/modernizing-mainframe-applications-with-kafka-and-the-open-enterprise-sdk-d96af5d63a54">“Modernizing Mainframe Applications with Kafka and the Open Enterprise SDK”</a> that takes a more detailed look at the SDK if you want more information on producing events from COBOL applications</p><h3>Transaction outbox pattern</h3><p>Not all applications fit Kafka’s programming paradigm. For instance, business-critical applications are typically comprised of short-lived transactions that run many thousands of times per second. These types of application (eg like those in CICS) simply don’t have enough time to wait for a Kafka client to connect to a cluster, send an event, wait for the acknowledgement (acks) and close the connection. In addition, a transaction may be required to backout at sync point but there is no way to recall any events it produced since Kafka cannot participate in distributed transactions or two-phase commit. This can lead to events being out of sync with the transactional state of the system.</p><p>The solution is to use the Transactional Outbox Pattern to produce events from the transaction to a local “outbox” that can participate in the transaction via two-phase commit (eg a file, queue or database table). Once events are written to the outbox (which will only happen if the transaction commit is successful) a separate producer task can read the events and send them to Kafka. As long as the producer task is written to respond to Kafka errors appropriately (eg with retries) and ensure that any events in the outbox will make it to Kafka eventually, then (eventual) consistency with the transactions state is maintained.</p><figure><img alt="A diagram showing the transaction outbox pattern consisting of a z/OS application sending events to a local event outbox as part of it’s Unit of Work, and a separate Event Producer process that reads from the outbox and produces the events to Kafka" src="https://cdn-images-1.medium.com/max/1024/1*kX5B1iYJuKbw-c-ZRLlocQ.png" /><figcaption>Transaction outbox pattern</figcaption></figure><p>This pattern is seen on many platforms, but it is particularly popular on z/OS because a lot of applications there are business critical and transactional in nature. Therefore, I’m often asked;</p><blockquote><em>“What should I use for the outbox?”</em></blockquote><p>Whilst there are number of options and every use case is different, a popular approach is to use IBM MQ.</p><p>There are a few reasons for this:</p><ul><li>It is transactional</li><li>It is highly performant, secure and resilient</li><li>Developers are familiar with its well-established API, and you can “PUT” a message onto a queue from almost any language and environment in z/OS</li><li>It has a Source Connector for Kafka Connect (included with MQ Advanced) that can quickly and reliably produce events to a Kafka topic for each message on a queue (once and once only)</li></ul><p>This last point is key, since it means that the outbox pattern can be implemented without having to implement and maintain the “producer” logic, freeing up developers to just focus on which events to produce from their applications.</p><figure><img alt="A diagram showing a z/SO applications sending events to Kafka via MQ and the MQ Kafka Connect Source Connector" src="https://cdn-images-1.medium.com/max/1024/1*VEWIC7U9kJeUseur_Jb2qA.png" /><figcaption>Using MQ as an transactional event outbox</figcaption></figure><p>Kafka Connect can be run on z/OS under USS to benefit from an optimised cross memory “bindings mode” connection to MQ. The Kafka Connect framework is part of the the open source Apache Kafka project and is fully supported on z/OS as part of <a href="https://www.ibm.com/products/event-streams">IBM Event Streams</a> (IBM’s distribution of Kafka for enterprise) Follow these links for more information is about the <a href="https://community.ibm.com/community/user/integration/blogs/amy-mccormick/2023/06/29/unlock-events-in-mission-critical-systems">IBM MQ Kafka Connectors</a>, <a href="https://ibm.github.io/event-automation/es/connecting/mq/zos/">MQ Kafka Connector setup on z/OS</a>, and <a href="https://community.ibm.com/community/user/integration/blogs/anthony-sharkey1/2023/07/31/ibm-mq-for-zos-933-performance-of-kafka-connectors">MQ Kafka Connector Performance</a></p><h3>Config based capture with CICS Event Processing</h3><p>In both the approaches above, the application needs to be changed and recompiled to produce an event. Unfortunately, for some customers I speak to, even small code changes to critical or performance sensitive applications present significant cost and/or business risk, and are sometimes not possible at all.</p><p>In this case producing events is obviously challenging, but thankfully not impossible. If the application is running in CICS Transaction Server, it is possible to use <a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=overview-cics-event-processing">CICS Event Processing</a> to capture and emit events from applications without any code change and without recompiling the application.</p><p>The config-based approach allows you to specify an <a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=processing-event-binding">Event Binding</a> that tells CICS when the event occurs. This could be something as simple as:</p><p><em>“When a particular transaction is invoked…</em>”</p><p>To something more complex like:</p><p><em>“When a particular Program is invoked using a particular User ID and it writes to a particular File and in the record being written there is a packed decimal at offset 25 with a value greater than 1000…”</em></p><p>The Event Binding also specifies what data to capture from the application and its context, how to format that data into an event, and how to emit the event via an <a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=formats-event-processing-adapters">Event Processing Adapter (EP Adapter)</a>. The <a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=adapters-mq-ep-adapter">IBM MQ EP Adapter</a> can be used to implement the Transaction Outbox pattern above without the need to change the application to PUT the event onto an MQ queue.</p><p><strong><em>Note:</em></strong><em> For a transaction outbox pattern, the typical CICS EP Emission Mode and Transactional Mode to use would be SYNC and TRANS respectively.</em></p><ul><li><em>SYNC performs the event emission as part of the transaction and, in this case, is roughly equivalent to adding an MQPUT1 to your CICS program. If the PUT fails the transaction is backed out, thus event emission is assured</em></li><li><em>TRANS ensures the event is only emitted if the transaction from which it was captured commits successfully.</em></li><li><em>Note when used with a persistent MQ queue, event delivery is also assured</em></li></ul><p><em>For more info on Emission and Transactional modes, and how CICS assures event emission see: </em><a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=works-how-cics-assures-event-emission"><em>https://www.ibm.com/docs/en/cics-ts/6.x?topic=works-how-cics-assures-event-emission</em></a></p><figure><img alt="A diagram showing captuing Events from a CICS application and emitting them to an MQ event outbox via the MQ EP Adapter. The MQ Kafka Connect Source Connecter is then used to produce the events to Kafka" src="https://cdn-images-1.medium.com/max/1024/1*_82x5REpBM4A5npwM1F3nw.png" /><figcaption>CICS Event Processing — Capturing events and producing to Kafka via MQ</figcaption></figure><p>Of course, the MQ EP Adapter is not the only EP Adapter available, there are other adapters both included in CICS and provided as <a href="https://www.ibm.com/docs/en/cics-ts/6.x?topic=adapters-custom-ep-adapter">Custom EP Adapters</a>.</p><h3>IBM Z Digital Integration Hub</h3><p>Another approach to integrate core systems of record applications on z/OS with Kafka is to use the IBM Z Digital Integration Hub (zDIH). IBM zDIH provides a highly efficient, scalable, real-time approach for sharing information. Information that flows into IBM zDIH is cached in-memory (with HA/DR support) and zDIH comes with a rich set of built-in interfaces &amp; connectors, such as a Kafka connector, to provide access to it.</p><figure><img alt="A diagram showing information flowing from z/OS transactions to IBM Z Digital Integration Hub where it can be accessed via REST/HTTP, JDBC and published as events to Kafka." src="https://cdn-images-1.medium.com/max/1024/1*3-bEFAV4kcJt-S3hUKmE8Q.png" /><figcaption>IBM Z Digital Integration Hub</figcaption></figure><p>Information in zDIH can be queried and/or integrated with eventing flows. Once you configure zDIH to emit onto Kafka topics, updates to cache(s) are automatically written to Kafka topics. IBM zDIH can integrate with CICS or IMS TM applications. In terms of integration with CICS, one common method of integration is to use the zDIH Custom CICS EP adapter. This adapter combined with zDIH processing enables a no-code approach to send information from CICS to zDIH on a successful commit, with transactional consistency, ordering and group related CICS events together on a unit of work boundary. If you configure zDIH to write to Kafka topics, information that lands in a zDIH cache will be emitted to Kafka. For more information about IBM zDIH, follow this links:</p><ul><li><a href="https://www.ibm.com/products/z-digital-integration-hub">IBM Z Digital Integration Hub</a></li><li><a href="https://www.ibm.com/docs/en/zdih?topic=isr-integrating-systems-record-by-using-cics-custom-ep-adaptor">Integrating Systems of Record by using CICS custom EP adaptor — IBM Documentation</a></li><li><a href="https://www.ibm.com/case-studies/mt-bank-application-modernization">https://www.ibm.com/case-studies/mt-bank-application-modernization</a></li></ul><figure><img alt="A diagram showing captuing Events from a CICS application and emitting them to zDIH via the zDIH Custom EP Adapter. zDIH then produces the events to Kafka" src="https://cdn-images-1.medium.com/max/1024/1*2wQTvesjkXHU68UkGEzttg.png" /><figcaption>CICS Event Processing — Capturing events and producing to Kafka via zDIH</figcaption></figure><p>Using IBM zDIH as an optimized mechanism for integration with event-based architectures provides the following unique benefits:</p><ul><li>Ordered representation of information in zDIH caches can be used for reconciliation in case of network delays between z/OS and Kafka Broker(s)</li><li>Fan-out mechanism for information in zDIH — in parallel, zDIH can be queried via JDBC, REST, updates sent via Kafka, shared with other JDBC compliant databases or MongoDB and point-to-point eventing</li><li>Cost optimizations from high zIIP eligibility</li></ul><h3>Conclusion</h3><p>So, to answer the question posed at the start of this article…</p><blockquote>Q: “How can I produce Kafka events from my z/OS applications?”;</blockquote><blockquote>A: “Use a Kafka Client Library from your application, just like on any other platform”.</blockquote><p>However, in the cases where the Kafka programming paradigm doesn’t fit with your application, or when making code changes is high risk and challenging, there are robust and performant solutions on z/OS (MQ, CICS Event Processing and zDIH) to help you extract events from your applications quickly and efficiently to meet your business needs.</p><p>Hopefully you found this article useful, if you have any questions, comments or ideas for follow-on topics please don’t hesitate to get in touch!</p><p><em>This article was written in collaboration with </em><a href="https://www.linkedin.com/in/mythili-venkatakrishnan-623983115/"><em>Mythili Venkatakrishnan</em></a><em> and </em><a href="https://medium.com/u/934409593f42"><em>Madhu</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac8cfb96f238" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>