在.net应用程序中使用IBM websphere MQ V.8

时间:2016-10-14 11:37:14

标签: .net ibm-mq

我想创建一个将在.net中使用websphere MQ的应用程序。我创建了 QueueManager,本地队列和频道,但我收到 MQRC_UNKNOWN_CHANNEL_NAME 错误。但我在连接到 MQQueueManager 时遇到错误。下面是我的代码`

public partial class Form3 : Form
    {
    const String connectionType = MQC.TRANSPORT_MQSERIES_CLIENT;

    // Define the name of the queue manager to use (applies to all connections)
    const String qManager = "QM1";

    // Define the name of your host connection (applies to client connections only)
    const String hostName = "aspireggn69(1415)";

    // Define the name of the channel to use (applies to client connections only)
    const String channel = "QM2Q2";



    public Form3()
    {
        InitializeComponent();

        Accept();
    }


    static Hashtable init(String connectionType)
    {
        Hashtable connectionProperties = new Hashtable();

        // Add the connection type
        connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType);

        // Set up the rest of the connection properties, based on the
        // connection type requested
        switch (connectionType)
        {
            case MQC.TRANSPORT_MQSERIES_BINDINGS:
                break;
            case MQC.TRANSPORT_MQSERIES_CLIENT:
            case MQC.TRANSPORT_MQSERIES_XACLIENT:
            case MQC.TRANSPORT_MQSERIES_MANAGED:
                connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName);
                connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
                break;
        }

        return connectionProperties;
    }


    public void Accept()
    {
        try
        {
            Hashtable connectionProperties = init(connectionType);

           ## Here I am getting error ##
            **MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties);**
        }
        catch (MQException ex)
        {

            throw;
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {


    }
}`

我不确定在Websphere MQ中消费消息需要创建哪种通道类型。任何帮助深表感谢。 Below is snapshot of channel 谢谢

1 个答案:

答案 0 :(得分:0)

您需要在队列管理器上创建服务器连接(SVRCONN)通道。您可以使用MQExplorer或MQSC Shell来创建通道。如果您正在使用MQSC - 运行命令

DEFINE CHANNEL (QM2Q2) CHLTYPE(SVRCONN)

这是最简单的形式,但足以开始。

之后,您需要配置连接到队列管理器的权限并使用队列。看here寻求帮助。