vb.net连接到MQ服务器

时间:2016-06-15 14:43:29

标签: vb.net ibm-mq mq

我将应用程序从vb6迁移到vb.net,除了从MQ服务器获取消息之外,每个事情都正常工作,当MQGet调用时,我得到2033错误(没有消息)
还附加了从工作vb6和不工作的vb.net发送到MQ的捕获消息,请帮忙吗?enter image description here

    '***********************************
    'Send(MQPUT) to MQSeries and CICS
    '***********************************
    PutMsgOpts = MQPMO_DEFAULT

    MsgDesc = MQMD_DEFAULT
    MsgDesc.Persistence = MQPER_PERSISTENT
    MsgDesc.MsgId = MQMI_NONE.Value
    MsgDesc.CorrelId = "AMQ!NEW_SESSION_CORRELID" 'if using MQBridge
    MsgDesc.ReplyToQ = gReplyToQ
    MsgDesc.ReplyToQMgr = gMQRplyMgrName
    MsgDesc.Format_Renamed = MQFMT_STRING

    'sPutMsg is composed of 8 byte program name(host/cics)
    ' plus data desired to pass as string only (dfcommarea)
    '************  MAX LENGTH IS 32776  *******************
    sPutMsg = gCICSPrgName & gsHost_Msg
    If Len(sPutMsg) <> 32768 Then
        sPutMsg = sPutMsg & Space(32768 - Len(sPutMsg))
    End If

    sMsgIdGet.Value = MsgDesc.MsgId

    '*******************************************
    'MQClose the queue for request sent to host
    '*******************************************
    'HOST-BYPASS
    MQCLOSE(Hconn, Hobj, MQCO_NONE, cC, Reason)
    'HOST-BYPASS

    '**********************************************************
    'MQOpen the queue for receiving the request from the host
    '**********************************************************

    'set up the queue name
    ObjDesc = MQOD_DEFAULT
    ObjDesc.ObjectName = gReplyToQ

    'Open
    'HOST-BYPASS
    MQOPEN(Hconn, ObjDesc, MQOO_INPUT_AS_Q_DEF Or MQOO_FAIL_IF_QUIESCING, Hobj, cC, Reason)
    'HOST-BYPASS
    'Hconn is set by MQseries in the Connect

    '**************************************
    'Receive (MQGET) from MQSeries and CICS
    '**************************************
    GetMsgOpts = MQGMO_DEFAULT
    GetMsgOpts.Options = MQGMO_WAIT Or MQGMO_CONVERT
    GetMsgOpts.WaitInterval = 10000 '20 seconds

    MsgDesc = MQMD_DEFAULT
    MsgDesc.Format_Renamed = MQFMT_STRING
    MsgDesc.Persistence = MQPER_PERSISTENT
    MsgDesc.CorrelId = sMsgIdGet.Value 'set correlId with MQGET msgid returned
    MsgDesc.MsgId = MQMI_NONE.Value
    MsgDesc.ReplyToQ = gReplyToQ
    MsgDesc.ReplyToQMgr = gMQRplyMgrName

    '** sGetMsg is composed of 8 byte program name(host/cics)
    '** plus data desired to pass as string only (dfcommarea)

    '************  MAX LENGTH IS 32776  *******************
    sGetMsg = New String(" ", 32768)

    'Command to receive from to MQSeries and CICS
    retryCount = 0
    cC = MQCC_OK + 1
    Reason = 2033
    Do While cC <> MQCC_OK And Reason = 2033
        MQGET(Hconn, Hobj, MsgDesc, GetMsgOpts, Len(sGetMsg), sGetMsg, readlen, cC, Reason)
        retryCount = retryCount + 1
        If retryCount > 1 Then Exit Do
    Loop 
    '************************
    'MQClose queue for input
    '************************
    MQCLOSE(Hconn, Hobj, MQCO_NONE, cC, Reason)

1 个答案:

答案 0 :(得分:0)

如果你得到2033,那么你知道队列在那里,但是你试图检索的消息不是。使用MQ Explorer或普通MQ样本以及runmqsc检查该队列上是否有任何消息,如果有,则其相关ID是否与您的程序提供的相匹配。

如果那里没有消息,那么请检查您发送给他们的CICS程序是否确实已收到您的消息,以及该程序是否已响应。

2033问题可能是您的编码问题,但更可能是配置和设置中的某些内容随着您的转换而发生了变化。您可能具有不同配置的队列管理器,具有不同配置的通道等。检查整个链。