- 論壇徽章:
- 0
|
本帖最后由 zh82186151 于 2013-08-23 10:21 編輯
public class MessageReceive
{
private static Logger log = Logger.getLogger(MessageReceive.class);
AS400 as400_;
DataQueue dq;
RecordFormat dataFormat;
public MessageReceive(AS400 as400) {
as400_ = as400;
// 產(chǎn)品隊列。
log.info("try to create the connection with scs host");
dq = new DataQueue(as400_, "/QSYS.LIB/WHPTF3G1GP.LIB/SKDTMP01.DTAQ");
log.info("successfully create the connection with scs host");
}
public void consume() {
try {
// 一旦隊列中有數(shù)據(jù),則立即出隊,否則等待
DataQueueEntry DQData = dq.read();
while (true) {
if (DQData != null) {
String msg = dq.read().getString();
log.info("收到的消息長度為:"+msg.length());
log.info("收到的消息為:"+msg);
log.info("讀取下一個記錄");
} else {
log.info("現(xiàn)在沒有消息,等待中;Nothing to process, will check again in 10 seconds"); }
}
} catch (Exception e) {
log.info("===========Exception found =======================");
e.printStackTrace();
}
}
public static void main(String[] args) {
// 構(gòu)造AS400對象,建立Java應(yīng)用程序與IBM i服務(wù)器的連接。
String hostname="10.21.33.127";
String user="candy";//AS400主機(jī)賬號名
String name="123456";//AS400主機(jī)密碼
AS400 as400 = new AS400(hostname, user, name);
MessageReceive consumer = new MessageReceive(as400);
consumer.consume();
}
}
跪求各位大神,以上寫法在程序啟動后能正確讀取AS400里面的dataqueue數(shù)據(jù)。但是對于新進(jìn)到AS400的dataqueue里面的數(shù)據(jù),我這個程序就讀不出來了。
是不是要刷新啥東西,茫然中。各位高手請指點小弟。拜謝! |
|