On 27/06/2022 7:09 am, Andrew Rowley wrote:
On 24/06/2022 3:17 pm, David Crayford wrote:
There's a more complete example here https://github.com/zsystems/java-samples/blob/master/MvsConsoleInteraction.java.

Using Object.wait()/notify() is a bit hairy. A more modern implementation would use Condition.await()/signal() but it's fine for this use case.

I cut as much as possible out of my example so there was less code to wade through to see the logic of the stop/modify etc.

There are some significant differences between the IBM example and mine:

- The IBM example does nothing until it receives the MODIFY command. My example does something (sleep), and responds to STOP and MODIFY commands. In a real implementation the sleep would be replaced with the actual function of the STC. I think this is more realistic, most STCs have a function they perform until they are stopped - they don't just respond to modify commands.

That's ok for a simple single threaded server but won't fly if you use a framework. We use the Spring Boot application framework which implements multiple concurrent services. We spin up a ConsoleController thread that shuts down the Spring application context on a STOP command for a clean termination. Our stuff can run on distributed systems so using a console listener is optional. Unless you REALLY need to run on z/OS (native code) you should strive to write Java applications that can run multi-platform.


- The IBM example returns true from handleStop which results in an immediate System.exit(0). I think this will result in an ugly abend if there is a dataset being processed at the time because it is not properly closed. My example is designed for a clean shutdown.

It's a simple sample. But it shows a useful model which is how we used it in more sophisticated environment.



Object.wait/notify is probably a reasonable approximation of an ECB. I would be more inclined to use higher level constructs.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to