- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试模拟 WebSphere MQ 原因代码 2009 以在下面的 JMS 代码中处理但无法获得它。相反,我得到了 2059。我所做的就是在进行连接调用时断开 SVRCONN channel 。如何在我的示例代码中获得 2009。
我在再次建立连接并使用事务 session 之前添加了 sleep 时间。还可以做些什么来正确处理原因代码 2009,最终队列管理器不会因频繁的不成功连接尝试而受到影响。
请找到代码。
private static void connectToQmgr(MQQueueConnectionFactory cf) {
// TODO Auto-generated method stub
MQQueueConnection connection = null;
MQQueueSession session = null;
MQQueue queue = null;
MQQueueSender sender = null;
//While Statement to make sure multiple connection tries are made until connection establishes
while (connection == null){
try {
connection = (MQQueueConnection) cf.createConnection();
session = (MQQueueSession) connection.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE);
queue = (MQQueue) session.createQueue("queue:///LQ");
sender = (MQQueueSender) session.createSender(queue);
//MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue);
long uniqueNumber = System.currentTimeMillis() % 1000;
TextMessage message = session.createTextMessage("MQJMSTest "+ uniqueNumber);
// Start the connection
connection.start();
sender.send(message);
session.commit();
System.out.println("Sent message:\\n" + message);
// JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000);
// System.out.println("\\nReceived message:\\n" + receivedMessage);
session.commit();
sender.close();
// receiver.close();
session.close();
connection.stop();
connection.close();
System.out.println("\\nSUCCESS\\n");
} catch (JMSException je) {
System.err.println("Caught JMSException");
// Check for linked exceptions in JMSException to catch MQException and Reason Codes
Throwable t = je;
while (t != null) {
// Write out the message that is applicable to all exceptions
System.err.println("Exception Msg: " + t.getMessage());
// Write out the exception stack trace
t.printStackTrace(System.err);
// Add on specific information depending on the type of exception
if (t instanceof JMSException) {
JMSException je1 = (JMSException) t;
System.err.println("JMS Error code: " + je1.getErrorCode());
if (t instanceof JmsExceptionDetail){
JmsExceptionDetail jed = (JmsExceptionDetail)je1;
System.err.println("JMS Explanation: " + jed.getExplanation());
System.err.println("JMS Explanation: " + jed.getUserAction());
}
} else if (t instanceof MQException) {
MQException mqe = (MQException) t;
System.err.println("WMQ Completion code: " + mqe.getCompCode());
System.err.println("WMQ Reason code: " + mqe.getReason());
//###################################################################################
//MQ Reason Code Error Handle here
//Currently Handling MQ Reason Code 2059 since unable to simulate 2009
//If connection handle exists make sure you close everything and add a wait interval and try a new connection again
if (mqe.getReason()== 2059){
System.out.println("Inside MQ Reson Code Handle");
if( connection != null){
try {
sender.close();
// receiver.close();
session.close();
connection.stop();
connection.close();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Add Wait Interval for 5 sec
try {
Thread.sleep(5000);
System.out.println("Inside Thread Sleep for 5 sec");
//Try New connecting Again
connectToQmgr(cf);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//##################################################################################
} else if (t instanceof JmqiException){
JmqiException jmqie = (JmqiException)t;
System.err.println("WMQ Log Message: " + jmqie.getWmqLogMessage());
System.err.println("WMQ Explanation: " + jmqie.getWmqMsgExplanation());
System.err.println("WMQ Msg Summary: " + jmqie.getWmqMsgSummary());
System.err.println("WMQ Msg User Response: "
+ jmqie.getWmqMsgUserResponse());
System.err.println("WMQ Msg Severity: " + jmqie.getWmqMsgSeverity());
}
// Get the next cause
t = t.getCause();
}
}
}
}
最佳答案
一个 2009
是 MQRC_CONNECTION_BROKEN
.您是否考虑过拔掉网络电缆或关闭连接所经过的网络接口(interface)?在笔记本电脑上运行代码时,这很容易。对于服务器,您可以尝试通过 SSH 代理或其他可以关闭的虚拟接口(interface)路由连接。
要回答问题的第二部分,请确保程序在重新连接尝试之间休眠几秒钟。或者,更好的是,使用现代版本的 WMQ 客户端并使用自动重新连接选项。这将进行几次快速重试,然后放慢速度以进行后续重试。
关于error-handling - 无法模拟 MQ 原因码 2009,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14505144/
我想使用foreach 来等待线程终止。但是,出现以下错误,没有实现。请告诉我。 cannot move out of `*handle` which is behind a shared refer
如果在TypoScript中未配置给定的typeNum,则TYPO3将抛出Exception/CMS/1294587217。 背景:从另一个系统迁移到TYPO3后,我们遇到了许多此类异常,因为在那里使
我需要一个带有 2 个 handle 的 slider ,一个可拖动,另一个固定。我正在使用 Jquery UI slider 。这是我到目前为止尝试过的:http://jsfiddle.net/8K
给定文件的HANDLE(例如C:\\FolderA\\file.txt),我想要一个函数,该函数会将HANDLE返回到包含的目录(在前面的示例中,它将是C:\\FolderA的HANDLE)。例如:
我想通过Automic在Unix中检查文件。如果该文件不存在,则应切换主机并检查文件是否存在。 问题是,我现在不执行错误处理。 每当脚本对象正在处理并且找不到文件时,skript都会中止。我在skri
鉴于: fruitid('Apple', 'Granny Smith', 1). fruitid('Apple', 'Cox', 2). fruitid('Pear', 'Bartlett', 3).
我有一个基于Spring的Wicket应用程序。 有一个池化的数据源bean。 现在,当MySQL死了时,我得到了带有堆栈跟踪的默认Wicket错误页面。 我想处理这种情况,只允许某些页面完全显示(静
我希望能够一次查询多个句柄,其中表格具有相同的格式,例如: 句柄:8000,8001,8003表:foo 想要做这样的事情: x:hopen `8000`8001`8003 x select from
我对在Swift 3中引发自定义异常有些困惑。 在C++中,我可以执行此操作以立即停止方法中的进程,抛出错误并进行处理,而无需进一步进行操作。 void foo() { try {
我一直在阅读MSDN开发人员COM指南。但是this page上的代码令人困惑。在此处复制: The following code sample shows the recommended way o
我有一个计划的批处理文件每天都会启动的过程。如果有错误,我需要内置错误处理才能重启进程。所有这些在大多数情况下都有效,但是我每个月都会收到一次超时错误,所以这是不可避免的。该进程不会将错误级别输出到b
我正在尝试从 chartlyrics API 获取歌词。我编写了一个可以运行但不能在循环内运行的 R 函数。我的脚本是: library(httr) library(RCurl) library(XM
在libuv事件循环中调用prepare handle callback和check handle callback的原因是什么? 最佳答案 I/O 操作发生在这两者之间,因此您可能希望在阻塞 I/O
我正在尝试在 R 中安装 BTYplus 包。 devtools::install_github("mplatzer/BTYDplus", dependencies=TRUE) library(BTY
我有一个Arduino,可以使用pySerialTransfer库通过串行与Mac正常通信,并且可以运行数小时。然后是某种形式的串行中断-尽管一夜间发生时我一直无法确定原因,但只要从笔记本电脑上拔下A
我是hooks和async/await的新手。我正在尝试处理Axios调用中的错误,并且不确定如何使用then/catch或try/catch处理我的API调用中的错误。 在基于类的React中,我将
我正在尝试向脚本中添加一些内容,以便让我知道我复制的文件是否已被完全复制。 基本上,我要压缩一堆文件,然后将它们发送到网络上的映射驱动器。然后,一旦文件被成功复制,我将脚本删除原始位置的文件。该脚本可
我有一个圆形 slider ,其中绘制了一条贝塞尔弧,一个圆弧在 slider 的起点和终点有两个 handle ,圆弧是在圆形 slider 中绘制的。 借助开始和结束 handle ,我可以沿着圆
删除 NULL 指针是安全的。 int* p = NULL; delete p; // ok, secure 句柄是什么? HANDLE h = NULL; CloseHandle(h
如果您没有在 dojo.connect 期间返回的“句柄”,您如何删除 dojo 连接事件? 我的示例涉及将一组事件动态分配给一组对象。 (为简单起见,事件是 onclick 和 ondblclick
我是一名优秀的程序员,十分优秀!