求救:关于MQ连接报错2059(应用程序错误)的问题?

sccly 2007-06-29 11:24:37
问题是我在程序中做了一个线程监测与MQ服务器的连接,一旦连接中断则重新连接,但是在现成运行的过程中,偶尔会报2059:应用程序错误,不知道为什么,应该不是连接数已满的问题,请大侠们帮助解决一下,源代码如下:
while (conn_flag && !isRunning)
{
try
{
//线程正在运行
isRunning = true;
//if (count == short.MaxValue - 1)
//{
// count = 0;
//}
//mqmanager.ConnQueueManager();
mqmanager.Initiate();
try
{
count = count + 1;
}
catch (Exception ex)
{

}
try
{
Srv.Writeln(count.ToString());
}
catch (Exception ex1)
{

}
//若连接成功则跳出循环,线程不再运行
//this.conn_flag = true;
//线程取得正常的运行结果,不需要再次运行
isRunning = false;
try
{
Thread.Sleep(1 * 1000);
}
catch (Exception ex2)
{

}
if (count == 1)
{
GlobalVariable.SetGlobalVariable("mq", mqmanager);
Srv.Writeln("连接MQ服务器成功!可以进行读写操作!");
GlobalVariable.WriteEventLog("MQ", "连接MQ服务器成功", EventLogEntryType.Information);
string auto = Srv.Configuration["AutoRun"];
if (bool.Parse(auto))
{
lisThread = new TheadManager("RCVMQ");
lisThread.StartListen();
GlobalVariable.SetGlobalVariable("ListenThread", lisThread);
}
if (GlobalVariable.GetGlobalVariable("player") != null)
{
//停止报警
//SoundPlay play = (SoundPlay)GlobalVariable.GetGlobalVariable("player");
//play.StopPlay();
}
this.isCatch = true;
}

}
//以下为对连接过程中出现异常的处理
catch (MQException ex)
{
count = 0;
if (GlobalVariable.GetGlobalVariable("mq") != null)
{
GlobalVariable.Remove("mq");
}
//modify-07-04-19
//if (GlobalVariable.GetGlobalVariable("ims") != null)
//{
// GlobalVariable.Remove("ims");
//}
if (!isCatch)
{
GlobalVariable.WriteEventLog("MQ", "连接MQ服务器异常 " + "异常代码" + ex.ReasonCode.ToString() + "异常信息" + ex.Message, EventLogEntryType.FailureAudit);
player = (SoundPlay)GlobalVariable.GetGlobalVariable("player");
if (player != null)
{
player.PlaySound();
}
this.isCatch = true;
}
try
{
//出现异常关闭监听线程
TheadManager thread = (TheadManager)GlobalVariable.GetGlobalVariable("ListenThread");
if (thread != null)
{
thread.CloseListen();
}
}
catch
{
Srv.Writeln("监听线程未启动");
}

string name = Thread.CurrentThread.Name;
//Srv.Writeln("连接MQ服务器的过程中出现异常,请查看日志!日志位置位于安装目录下MQ文件夹下"+ex.ToString());
switch (ex.ReasonCode)
{
//连接断开
case 2009:
//队列管理者无效或未知
case 2058:
//队列管理者无效
case 2059:
//意外的错误发生
case 2195:
//服务器正在启动
case 2161:
//服务器正在关闭
case 2162:
//阻塞线程三秒,之后重新连接,重复3次,如果连接不上,置空
//for (int i = 0; i < 3; i++)
{
Srv.Writeln("正在重新连接MQ服务器!若没有恢复请及时联系MQ服务器管理员!" + ex.ToString());

//线程十秒后再次运行
Thread.Sleep(5 * 1000);
fm = new FileManager("MQ\\MQLog.log");
fm.WriteStringToFile(DateTime.Now.ToString() + " 连接MQ服务器的过程中出现问题 " + ex.Message.ToString() + "错误代码:" + ex.ReasonCode + "错误提示:" + ex.ToString());
fm.CloseStreamWriter();
}
//线程一次运行已经结束,但未得到预期的结果,需要再次运行
isRunning = false;
conn_flag = true;
mqmanager.SetQueueManager(null);
break;
//无权访问服务器队列管理者
case 2035:
//线程不需要再次运行,直接写入日志文件,并报警
conn_flag = false;
fm = new FileManager("MQ\\MQLog.log");
fm.WriteStringToFile(DateTime.Now.ToString() + " 无权访问MQ服务器队列管理者 " + ex.Message.ToString() + "错误代码:" + ex.ReasonCode);
fm.CloseStreamWriter();
mqmanager.SetQueueManager(null);
break;
//其他异常
default:
//线程不需要再次运行,直接写入日志文件,并报警
conn_flag = true;
fm = new FileManager("MQ\\MQLog.log");
fm.WriteStringToFile(DateTime.Now.ToString() + " 连接MQ服务器的过程之中出现未知的异常 " + ex.Message.ToString() + "错误代码:" + ex.ReasonCode);
fm.CloseStreamWriter();
mqmanager.SetQueueManager(null);
break;
}
}
finally
{
//关闭MQ服务器队列管理器
mqmanager.CloseManager();
}
...全文
6373 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjp_116 2010-05-07
  • 打赏
  • 举报
回复
我现在有点搞不清楚,好像在c#高级编程中(第四版)有关于MQ的内容,好像是微软开发的中间件,不过还有一个是IBM开发的,不知道你说的MQ是哪个
shlisa1 2010-05-06
  • 打赏
  • 举报
回复
这里有牛人 www.shlisa.com
hejialin666 2010-05-06
  • 打赏
  • 举报
回复
很牛!
UltraBejing 2008-05-01
  • 打赏
  • 举报
回复
等待牛人来答.
yinglz 2007-08-20
  • 打赏
  • 举报
回复
2059 0x0000080b MQRC_Q_MGR_NOT_AVAILABLE
可能是活动通道连接数量超过上限,可以通过修改ini配置文件,增大连接数
liusdream 2007-07-03
  • 打赏
  • 举报
回复
2059
Queue manager not available for connection.
Corrective action: Ensure that the queue manager has been started. If the connection is from a client application, check the channel definitions.
sccly 2007-06-29
  • 打赏
  • 举报
回复
这是我在事件日志查看器中查看到的日志

远程通道当前不可用。

因通道 'RCVMQ.CHL' 当前在远程系统上不可用,通道程序已终止。这可能是因为该通 道是禁用的或远程系统没有足够的资源来运行另外的通道。

检查远程系统以确保通道是可用于运行的,然后重试该操作。
sccly 2007-06-29
  • 打赏
  • 举报
回复
如果有用C#开发MQ程序的可以交流一下,QQ283633218 白天在线
Rubi 2007-06-29
  • 打赏
  • 举报
回复
http://bbs.chinaunix.net/viewthread.php?tid=833625&extra=&page=2
参考这篇文章

2,633

社区成员

发帖
与我相关
我的任务
社区描述
WebSphere 是 IBM 的软件平台。它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。
社区管理员
  • WebSphere社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧