vb从.NET访问MQ时出错



我有一个VB.NET控制台应用程序,它必须将消息写入队列(驻留在大型机上)。我们有所有的集群和一切由我们的管理员设置。我们已经有了一个现有的windows服务,它可以成功地侦听消息,还可以将消息写入各种队列。

我基本上已经重新使用了windows服务项目中的大部分代码。

但是,当我尝试访问队列管理器时,我遇到了异常"MQRC_HOST_NOT_AVAILABLE"。Websphere MQ文件夹中的错误日志显示

AMQ9213: A communications error for  occurred.
EXPLANATION:
An unexpected error occurred in communications.
ACTION:
The return code from the  call was 0 (X'0'). Record these values and tell the systems administrator. 

以下是完整的异常堆栈。

IBM.WMQ.MQException was unhandled
Message="MQRC_HOST_NOT_AVAILABLE"
Source="amqmdnet"
StackTrace:
   at IBM.WMQ.MQBase.throwNewMQException()
   at IBM.WMQ.MQQueueManager.Connect(String queueManagerName)
   at IBM.WMQ.MQQueueManager..ctor(String queueManagerName)
   at LPMQtoClarify.Module1.Main() in D:LPDEVDevelopersX173036_SanthanamLPMQtoClarifyLPMQtoClarifyModule2.vb:line 47
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

这是我代码的一部分。异常发生在以下行

QueueManager = New MQQueueManager(TransParmRec.MQManager)

感谢您的帮助。谢谢

Dim pos As Integer = 3
Dim clarifyReturnCode As Integer = 0
Dim clarifyRequestMessage As String = String.Empty
Dim QueueManager As MQQueueManager
clarifyQLauncherName = ConfigurationManager.AppSettings.[Get]("MQ_CLARIFY_REQUEST_Q")

Dim initRetCode As Integer = 0
Dim errorMessage As String = ""
initRetCode = GetTransInfo(TransParmRec, dbConnectionString, errorMessage)

MQEnvironment.Hostname = TransParmRec.MQHostName
MQEnvironment.Channel = TransParmRec.MQChannel
If TransParmRec.PortNumber.ToString().Length > 0 Then
    MQEnvironment.Port = Convert.ToInt32(TransParmRec.PortNumber)
End If
If TransParmRec.SecExit.ToString().Length > 0 Then
    MQEnvironment.SecurityExit = TransParmRec.SecExit
End If

QueueManager = New MQQueueManager(TransParmRec.MQManager)
Using sw As New StreamWriter("C:FCLARIFYMQ.REQ", True)
    If QueueManager Is Nothing Then
        sw.WriteLine("Queue Manager is null")
    Else
        sw.WriteLine("Queue Manager is not null")
    End If
End Using

重新检查主机名或端口号。如果主机名或端口号无效,则返回MQRC_HOST_NOT_AVAILABLE。

当我在不同的用户帐户下运行应用程序时,代码就工作了。MQ权限是为不同的用户帐户设置的,该帐户与管理员帐户不同。

最新更新