CRPence skrev den 10-08-2008 00:16:
Presumably already known, includes that SNDRPY is available from:

Thank you for your very thorough answer. It gave me a lot of pointers and help to figure this out (which gave me the vocabulary to discover how others discussed this previously without me understanding it to be the issue :)

My goal was to provide the Java program the ability to detect and handle the MSGW situation without a human needing to use a green screen. By using a second AS400 object (hence a different prestarted job answering) I can watch the job with something like

Job j = new Job(systemi, job.getInternalJobIdentifier());
do {

Either a default response is already known or a developer can be presented with formatted versions of j.getCallStack(Job.INITIAL_THREAD) and jobLog.getMessages(0, jobLog.getLength()) to determine a specific response in the situation.

That the inquiry message [for which a reply message is being awaited] would be in QSYSOPR versus some other message queue, is an assumption.
I assume for now that the inquiry message is in QSYSOPR (our guru is on vacation), so this snippet will send the response and delete the message:

String jobId = getJobId(job.getNumber(), job.getUser(), job.getName());
MessageQueue queue = new MessageQueue(systemi, "/QSYS.LIB/QSYSOPR.MSGQ");
Enumeration messages = queue.getMessages();
while (messages.hasMoreElements()) {
QueuedMessage message = (QueuedMessage) messages.nextElement();
if (message.getType() == AS400Message.INQUIRY) {
message = queue.receive(message.getKey(), 0, MessageQueue.SAME, MessageQueue.ANY);
String number = message.getFromJobNumber();
String user = message.getUser();
String name = message.getFromJobName();
if (jobId.equals(getJobId(number,user,name))) {
System.out.println("Got it!");
queue.reply(message.getKey(), response);
private static String getJobId(String number, String user, String name) {
return number + "/" + user + "/" + name;

Hopefully this can help others, and if there is comments I'd like to hear them :) Now I just need to get this to production quality :-S

Thanks again.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.