|
Thanks for all the input from everyone. I will give this a try. -----Original Message----- From: owner-java400-l@midrange.com [mailto:owner-java400-l@midrange.com]On Behalf Of pluta@nexgensoftware.com Sent: Tuesday, August 24, 1999 12:48 AM To: JAVA400-L@midrange.com Subject: Re: Data Queues To the Toolbox, each entry on the Data Queue is just a stream of bytes or all text. When you read an entry from the DataQueue object you get a DataQueueEntry object. From DataQueueEntry you getData() or getString(). If you call getString(), the Toolbox assumes the data is all text and converts it from EBCDIC to unicode before putting it in the String object. If you call getData(), the Toolbox just hands you a byte array with the data it read off the queue. Your code extracts the data. You can use a Toolbox Record object or pull the data out using simple converters. In your case I think the Record object is probably more work than you need. It would be easier to use the AS400Text object to convert the bytes into a String. David Wall AS/400 Toolbox for Java --------- The other option is to use the data structure capabilities of the Toolbox. This is what I do in my JDQM/400 routines. In order to support a common interface between RPG servers and Java clients, I've created a set of AS/400 programs that wrapper the data queue calls (QSNDDTAQ and QRCVDTAQ). RPG servers call these programs directly. The Java clients call them using my JdqmSession classes, which use data structures to break down the data queue messages. Here's a few excerpts from the JdqmSession class: DEFINE A STRUCTURE static AS400DataType[] dqmMsg = { new AS400Text(10), new AS400Text(10), new AS400Text(2), new AS400Text(2), new AS400Text(2), new AS400Text(2), new AS400Text(2), new AS400ByteArray(200) }; private Object[] dqmMsgJava = new Object[0]; private AS400Structure dqmMsgCvt; INITIALIZATION AS400 sys = Pbd400.getAS400(); dqmParms = new ProgramParameter[1]; dqmParms[0] = new ProgramParameter(230); dqmCRcv = new ProgramCall(sys); dqmCRcv.setProgram("/QSYS.LIB/" + syslib + ".LIB/DQMCRCV.PGM", dqmParms); dqmMsgCvt = new AS400Structure(dqmMsg); RECEIVE public Object[] receive() { try { if (dqmCRcv.run() == false) {(dqmMsg);b System.out.println("dqmCRcv failed."); System.exit(0); } } catch (Exception e) { System.out.println("dqmCRcv Exception: " + e.getMessage()); } dqmMsg400 = dqmParms[0].getOutputData(); return (Object[]) dqmMsgCvt.toObject(dqmMsg400, 0); } There's not a lot of error checking in this, but what ends up happening is that the receive() method returns an array of objects corresponding to the fields defined in the structure. For example, objectArray[0] would contain a String made from the first 10 bytes of the message. I find this technique much less cumbersome than using the Record class. This example and all the others are in PBD1.2P, which can be downloaded from my website: http://www.zappie.net Where the AS/400 speaks Java with an RPG accent +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com 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.