- 论坛徽章:
- 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;
// 产品队列。
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 {
// 一旦队列中有数据,则立即出队,否则等待
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("现在没有消息,等待中;Nothing to process, will check again in 10 seconds"); }
}
} catch (Exception e) {
log.info("===========Exception found =======================");
e.printStackTrace();
}
}
public static void main(String[] args) {
// 构造AS400对象,建立Java应用程序与IBM i服务器的连接。
String hostname="10.21.33.127";
String user="candy";//AS400主机账号名
String name="123456";//AS400主机密码
AS400 as400 = new AS400(hostname, user, name);
MessageReceive consumer = new MessageReceive(as400);
consumer.consume();
}
}
跪求各位大神,以上写法在程序启动后能正确读取AS400里面的dataqueue数据。但是对于新进到AS400的dataqueue里面的数据,我这个程序就读不出来了。
是不是要刷新啥东西,茫然中。各位高手请指点小弟。拜谢! |
|