This Java web application demonstrates how to emit and consume CICS events in Java using the JCICS API.
This sample shows how to consume and emit CICS events using Java code. Events are emitted from a Java EE servlet using the JCICS Event API, equivalent to an EXEC CICS SIGNAL EVENT
call. This event is processed by CICS event processing and is handled by an event processing adapter. This adapter is configured to call the CICS program EVNTCONS
when an event is received.
The CICS program EVNTCONS
is a Java EE program designed to consume CICS events and, in this basic sample, log that an event was received to STDOUT.
- CICS TS V5.5 or later
- A configured Liberty JVM server
- Java SE 1.8 or later on the workstation
- Either Gradle or Apache Maven on the workstation (optional if using Wrappers)
The project consists of two parts:
- cics-eventprocessing-java-webapp - the Java source code for this example
- cics-eventprocessing-java-bundle - the bundle definition for this example
There are two Java classes:
EventEmitter.java
- a servlet that emits CICS eventsEventConsumer.java
- the Java code to define the CICS program resourceEVNTCONS
and consume the CICS events
The code is built into a WAR file, packaged into a CICS bundle, and deployed to a Liberty JVM server as a web application.
The CICS bundle contains the following elements:
EVNT.transaction
- transaction which targets theEVNTCONS
programACCOUNTADAPTER.epadapter
- event processing adapter which starts theEVNT
transactionACCOUNT.evbind
- event binding which targets theEVENTADAPTER
adpaterWARBUNDLE
- Java WAR bundle is added when built
There are several ways to build this project. We suggest you build with a build toolkit such as Gradle or Maven.
./gradlew assemble
This will compile the Java code, build a WAR file and package it and the EP adapter and Event binding into a CICS bundle as a ZIP file at ./cics-eventprocessing-java-bundle/build/distributions/cics-eventprocessing-java-bundle-0.0.1-SNAPSHOT.zip
./mvnw verify
This will compile the Java code, build a WAR file and package it and the EP adapter and Event binding into a CICS bundle as a ZIP file at ./cics-eventprocessing-java-bundle/target/cics-eventprocessing-java-bundle-0.0.1-SNAPSHOT.zip
You will need to define a CICS Liberty JVM server with the name DFHWLP
. This name can be modified in the pom.xml
of the cics-eventprocessing-java-bundle module.
The Liberty JVM server will need the following features installed at a minimum: cicsts:core-1.0
and cicsts:link-1.0
and servlet-3.1
. For example:
<server name="cics-eventprocessing-java">
<featureManager>
<feature>cicsts:core-1.0</feature>
<feature>cicsts:link-1.0</feature>
<feature>servlet-3.1</feature>
</featureManager>
<!-- More configuration -->
</server>
A template server.xml
is provided here.
- Upload the built bundle ZIP file to zFS on your z/OS system in binary using FTP, or similar
- Logon to zFS on your z/OS system using SSH, OMVS, or similar
- Extract the ZIP file contents, for example using command
unzip /path/to/bundle.zip
- In CICS, define a new
BUNDLE
resource with theBUNDLEDIR
set to the extracted ZIP file contents, then install theBUNDLE
resource
You can confirm the application has started by inquiring the state of the BUNDLE
, for example using transaction CEMT INQUIRE BUNDLE
, or the CICS Explorer bundle view.
A message will be written to the Liberty messages.log
file to confirm the application has started, and the base URL for this application.
- Use a browser to target the address http://my.zos:9080/cics-eventprocessing-java-webapp/emit?event=ACCOUNT replacing
my.zos
with the hostname of your z/OS system and9080
with the port the Liberty JVM server is listening on. - View the JVM server CURRENT.STDOUT file, this should contain two log messages
- Emitted event
- Consumed event
You can also emit an event using EXEC CICS SIGNAL EVENT(event)
either in another CICS program, or using transaction CECI
.
This project is licensed under Eclipse Public License - v 2.0.