CICS - Group home

Using Node.js with CICS Transaction Server for z/OS

By Mark Cocker posted Thu August 06, 2020 01:12 PM

  

CICS has always been unique in providing developers the choice to use the language most appropriate to tackle the business and technical requirements – be it with Java, COBOL, PL/I, C/C++, or Assembler. CICS TS V5.5 extended this choice by adding support for Node.js.

Node.js is a very popular runtime for JavaScript applications on server platforms. It is efficient at handling intensive network and database interactions. For example, full-stack developers already use Node to serve web applications and APIs that consume information from backend systems such as CICS and IBM Db2.

The integration of Node.js with CICS brings two diverse user communities together; the ecosystem of CICS products and tools can be used to manage a collection of Node.js applications, and the power and flexibility of a modern language is brought to CICS.

If you’re new to CICS - a powerful mixed language application server on the IBM Z mainframe - find out more by watching the video course series or reading What is CICS Transaction Server for z/OS?

Node.js is a good match for CICS

From a CICS perspective, many businesses that use CICS also expose their core business applications as RESTful APIs, for example using CICS web services or z/OS Connect Enterprise Edition. In some cases, APIs need additional logic for example to combine several APIs, or to augment them with data from other sources.

Node.js is ideally suited for integrating services and, if those services or microservices expose useful function from COBOL applications, it keeps a business responsive and able to quickly fulfil business requirements from its existing CICS application.

From a development perspective, Node.js enables JavaScript developers to use their skills to write applications that run on the server, for example to host the RESTful API components that are called by JavaScript running in the browser.

Although Node.js applications can be hosted on many operating systems and cloud environments, hosting them on z/OS - along with other applications and the data that they consume - makes management easier, minimizes the likelihood of communications performance degradation, and takes advantage of the strengths of the mainframe, such as security, resilience, and cost-effective scalability.

Have a look at article Reasons to Host your Node.js Applications on z/OS for even more benefits of IBM SDK for Node.js – z/OS, including its eligibility for IBM Z container pricing.

As a Node.js developer, you’ll be on familiar ground

To develop for CICS, you can use your existing development and testing tools and a sample is provided to get you going quickly.

You don’t need to know all the ins-and-outs of CICS. CICS services, such as the EXEC CICS commands and transaction and security context, are not available to Node.js applications. Instead, Node.js applications can call CICS programs using either network services, or, for improved response times, they can use a locally optimized memory transport provided by the ibm-cics-api module.

To deploy the Node.js application, it needs to be included in a bundle of CICS resources (a CICS bundle. You do this either by using the CICS Explorer which is an Eclipse-based tool to manage CICS bundles, systems and resources or by using the Zowe CLI CICS deploy plug-in.

As a CICS system programmer, Node.js fits right in

A Node.js application is deployed as part of a CICS bundle. Like with any CICS bundle, you can automate the build and deployment using the CICS build toolkit and DFHDPLOY utility.

Once the CICS bundle is installed, a NODEJSAPP resource provides you with basic information about the Node.js application and the directory location its log files, and you can view this with CEMT. You can get more detailed information from modules such as Node Application Metrics that can be aggregated with other Node.js applications using Prometheus.

Node.js applications are run on general purpose CPs, and some operations use the Integrated Cryptographic Services Facility (ICSF). For details, see Installing and configuring IBM SDK for Node.js – z/OS.

How do I run a Node.js application on my system?

You’ll need to download and install CICS Transaction Server for z/OS V5.5 or V5.6, CICS Explorer 5.5 or later, and IBM SDK for Node.js – z/OS, V8 or later.

If you haven’t got a Node.js application of your own, pick up our sample from the CICS installation directory samples/nodejs/nodejsivp. Copy this to a private directory, modify the profiles/ivp_sample.profile with a free TCP/IP port, then define and install a BUNDLE resource. The log file .stdout under the working directory (WORK_DIR) provides messages about the URL location that you can copy into your browser to call the JavaScript program.

  1. Create a CICS bundle using CICS Explorer V5.5.

  2. Copy in the Node.js application into a sub-directory of the CICS bundle.

  3. Select New > Node.js Application and you’ll be guided through through selecting the Node.js application start script and creating a profile. The profile is used to customize the installation location of Node.js in zFS, and environment variables required by your application, such as TCP/IP port and working directory for log files.

  4. Export the CICS bundle to zFS. If your application requires modules that are not already installed in zFS, use Node Package Manager (npm) that is provided with IBM SDK for Node.js – z/OS to install them either in a global location or within the CICS bundle.

  5. The CICS system programmer defines and installs a BUNDLE resource in CICS. The Node.js application will be started.

Need to know more about Node.js?

Node.js is a server-side JavaScript runtime platform. It is lightweight, efficient, and designed to build scalable network applications.

JavaScript is a high-level, interpreted programming language used by most web sites to run code inside web browsers to create exciting and responsive pages. This has led to JavaScript becoming one of the most widely used languages today.

Node.js applications typically consists of a .js file that is the initial script, a package.json file that describes the modules the script requires, and other scripts, modules, and web site files.

Node.js application are built using a modular architecture:

Node.js encourages JavaScript applications to be written using modules, for example Express provides a web framework, and LoopBack provides an API framework. There are many Node.js modules available for free on the NPM public registry for most tasks, saving considerable time for application developers. Most modules are written in JavaScript and a few are written in C/C++. The npm utility supplied with IBM SDK for Node.js – z/OS can download, compile and install these modules on z/OS from the public or a private repository.

Node.js applications are inherently asynchronous:

Node.js applications are inherently asynchronous. They don’t share in the implicitly single-threaded mentality of traditional CICS languages and programs.

For example, after enabling the Node.js runtime, the application is started and typically defines listener code to be called when an HTTP request is received, and then returns to the runtime. For each HTTP request, a new instance of the listener code is called to process it. Similarly the Node.js application can use this event-listener model to process other API or database requests that involves I/O delays. This allows the runtime to efficiently run all JavaScript code in a single thread and delegate I/O to a few worker threads. If this model sounds familiar, that’s because it's similar to what CICS itself offers for other languages. Node.js applications are written to expect this type of high volume workload, and the Node.js runtime implements the sub-dispatching that is required within that single application.

Node.js is supported by the community:

There is a large community of full-stack developers able to design and code the UI, APIs and server components, and Node.js is their preferred runtime. The Node.js Foundation claim there are 9 million instances of Node.js.

Calling CICS programs:

Although Node.js applications can call CICS programs using network services, for improved response times they can also use a locally optimized memory transport provided by the ibm-cics-api module.

Links