- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在使用 JTOpen 的 KeyedDataQueue
类提供的 read() 方法时,我检测到一个奇怪的行为。
我设置了一个 90 秒的超时,当达到超时时,我的调用方法执行将恢复 99% 的读取执行。
至于另外 1% 的超时未被考虑/达到,我的调用方法保持挂起...
经过一番搜索,我找到了这篇文章:
http://archive.midrange.com/java400-l/201112/msg00056.html
基本上它证实了我的怀疑:
"I also found that the DataQueue.read() timeout functionality is server side so if the TCP/IP connection is silently torn down (which I believe is the underlying cause of this) it will still hang. "
我正在使用 JTOpen 的 7.2 版,我意识到 7.9 版已经在那里了。我没有更新到 7.9,因为我有很多使用稳定的 7.2 的关键应用程序,这确实是让我考虑更新到 7.9 的第一个真实场景。
为了帮助我做出这个决定,我非常希望得到您的反馈,尤其是那些遇到过这种情况并最终通过升级 JTOpen 解决它的人。
具体来说,这个问题是否有解决方法,升级 JTOpen 是否有助于解决这个问题?将 JTOpen 升级到 7.9 会破坏 7.2 中的所有功能吗?
最佳答案
如上所述,数据队列读取超时是服务器端的。如果 iSeries 和客户端之间的 TCP 连接停止或终止,客户端将等待直到套接字超时。我的解决方案是建立一个故障安全中断器来停止停滞的读取。这是如何完成此操作的快速代码示例。
public class DataQueueListenerExample {
//This executes our Interrupter after the specified delay.
public final ScheduledThreadPoolExecutor interruptExecuter = new ScheduledThreadPoolExecutor(1);
//the dataqueue object.
protected DataQueue dataqueue;
public DataQueueEntry read(int wait)
{
ScheduledFuture<?> future = null;
try {
//create our fail safe interrupter. We only want it to
//interrupt when we are sure the read has stalled. My wait time is 15 seconds
future = createInterrupter(wait * 2, TimeUnit.SECONDS);
//read the dataqueue
return this.dataqueue.read(wait);
} catch (AS400SecurityException e) {
} catch (ErrorCompletingRequestException e) {
} catch (IOException e) {
} catch (IllegalObjectTypeException e) {
} catch (InterruptedException e) {
//The read was interrupted by our Interrupter
return null;
} catch (ObjectDoesNotExistException e) {
} finally{
//Cancel our interrupter
if(future != null && !future.isDone())
future.cancel(true);
Thread.interrupted();//clear the interrupted flag
interruptExecuter.shutdown();
}
return null;
}
public ScheduledFuture<?> createInterrupter(long timeout,TimeUnit timeunit)
{
return interruptExecuter.schedule(new Interrupter(),timeout,timeunit);
}
class Interrupter implements Runnable
{
final Thread parent;
Interrupter()
{
this.parent = Thread.currentThread();
}
@Override
public void run() {
parent.interrupt();
}
}
}
我强烈建议在出现 InterruptedException 后在新的 AS400 连接上重新创建 DataQueue 对象。您的 AS400 连接可能已停止。Thread.interrupt 非常有用,但要谨慎使用。
关于java - JTOpen KeyedDataQueue 读取()超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16317554/
当使用 JTOpen 中的 UserSpace 对象从 IBMi 系统读取数据时,使用 UserSpace.read() 方法将数据从 EBCDIC 转换为 ASCII 还是保留在 EBCDIC 中。
我正在开发一个 Web 应用程序(在 Tomcat 上运行),该应用程序使用 JTOpen ProgramCall 类 (com.ibm.as400.access.ProgramCall) 调用 IB
在使用 JTOpen 的 KeyedDataQueue 类提供的 read() 方法时,我检测到一个奇怪的行为。 我设置了一个 90 秒的超时,当达到超时时,我的调用方法执行将恢复 99% 的读取执行
我正在尝试使用 jt400 连接到 AS400 计算机。当我第一次尝试使用 tn5250 连接到 AS400 时,有一列询问设备名称。示例如下: 当我尝试编写 java 代码来设置与 AS400 的连
给定一个来自 JTOpen 的 DecimalDataArea,在读取和写入数据区时,AS400 上的对象是否被锁定,以防止 AS400 上的其他应用程序同时写入? 这是 javadoc 中关于如何读
我们将在不久的将来实现一个解决方案来使我们的 iSeries 应用程序现代化编写为带有一些存储过程的 RPG 程序,我们首选的方法是利用 Java 在该领域提供的最新和最强大的功能。 通过谷歌搜索和检
有一个 ProgramCall,运行时会在 QTEMP 文件中写入 PF。我想访问 QTEMP 内的 PF,但它说在 QTEMP 库中找不到 CPF3012 FIle。由于每个作业都有自己的 QTEM
我在 jython 中与 AS400 对话时有以下内容: system = AS400(ip, USER, PWORD) obj = ObjectDescription(system, 'qsys',
我们正在使用 JTOpen 连接到我们的 AS/400 机器,我正在尝试解决使用这种类型的集成时存在 SQL 注入(inject)漏洞的风险。 请注意,我们仅使用 API 的调用程序部分 - 而不是
我是一名优秀的程序员,十分优秀!