Monitor and handle MSGW messages on a job on an IBM i-series (AS/400) from Java

风格不统一 提交于 2020-01-03 05:31:11

问题


Does anyone know how one can automatically reply to messages with status MSGW that block a job on an IBM i-series (AS/400)?

I'm using the jt400/jtopen library to access a program on an AS/400 from Java. I'm using the com.ibm.as400.access.ProgramCall class, which works fine, unless the program fails for some reason. As with almost any program, failures will happen sometimes, but unfortunately, in this case, it does not result in a status message or an exception. Instead, the calling thread just hangs. What's worse, any call to the AS/400 to get information on the Job (another class in jt400 that mostly does what you would expect) backing the queue will hang as well.

I could of course monitor the thread in which the call runs and simply kill it after waiting for a while, but that's a last resort. Getting an error message back from the system would be nice.


回答1:


You could try execute this command before invoke your pcml with com.ibm.as400.access.CommandCall.run() method:

CHGJOB INQMSGRPY(*DFT)

It sets 'C' as default answer for all messages.

but you should ensure you have log of the messages in order to know the problem which generates this message

Regards,




回答2:


I don't believe Java can directly trap errors that occur on the other side of that API. What I've done is to 'harden' the RPG (IBM i side) program so that it monitors for errors rather than let the default error handler get them. When an error occurs, the RPG program gracefully terminates and passes back an error code or even the entire message back to the Java application.




回答3:


I've found that you can use the timeout mechanism of ExecutorService to interrupt a ProgramCall in MSGW.

You must discard the AS400 object afterwards, and the server job is still in MSGW, but at least you can continue on the Javaside.

(You need to use a separate AS400 object if you want to investigate on the hanging job.)



来源:https://stackoverflow.com/questions/4995970/monitor-and-handle-msgw-messages-on-a-job-on-an-ibm-i-series-as-400-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!