设为首页 收藏本站
查看: 1573|回复: 0

[经验分享] 基于IBM MQ的.net开发遇到的头疼问题

[复制链接]

尚未签到

发表于 2015-10-3 13:52:17 | 显示全部楼层 |阅读模式
  背景:
  MQClient 对接MQServer  服务器都是server2003,只开通了1314端口进行访问。对方IT说没有开通pin功能,但是可以对联。
  
  开始报2035 没有权限的异常。发现对方MCA标示没有设置,并且对方不愿意修改,说是成型的系统,有很多人在用。
  
  最后头疼了好长时间,在一位前和他们对接过系统的公司的人那里找到了解决方法,在系统中创建一个对方指定的用户。
  
  用此用户登录。(为此用户设置mqm权限)
  
  不知道是否MQ服务器安装的时候都应该指定MCA用户标示,是否不设定的情况下更好的理由?
  
  另从IBM扒的代码参数传递的时候用hashtable的方法传参数,看起来不错,记下来。
  
  

DSC0000.gif DSC0001.gif 代码

// ===========================================================================
// Licensed Materials - Property of IBM
// 5724-H72
// (c) Copyright IBM Corp. 2003, 2005
// ===========================================================================
using System;
using System.Collections;
using IBM.WMQ;
class MQSample
{
    // The type of connection to use, this can be:-
    // MQC.TRANSPORT_MQSERIES_BINDINGS for a server connection.
    // MQC.TRANSPORT_MQSERIES_CLIENT for a non-XA client connection
    // MQC.TRANSPORT_MQSERIES_XACLIENT for an XA client connection
    // MQC.TRANSPORT_MQSERIES_MANAGED for a managed client connection
    const String connectionType = MQC.TRANSPORT_MQSERIES_CLIENT;
    // Define the name of the queue manager to use (applies to all connections)
    const String qManager = "QM_ORANGE";
    // Define the name of your host connection (applies to client connections only)
    const String hostName = "172.16.1.76(5678)";
    // Define the name of the channel to use (applies to client connections only)
    const String channel = "CLIENT.QM_ORANGE";

    /// <summary>
    /// Initialise the connection properties for the connection type requested
    /// </summary>
    /// <param name="connectionType">One of the MQC.TRANSPORT_MQSERIES_ values</param>
    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);
                connectionProperties.Add(MQC.USER_ID_PROPERTY, userid);
                connectionProperties.Add(MQC.CCSID_PROPERTY, ccsid);
                connectionProperties.Add(MQC.PASSWORD_PROPERTY , password);
                break;
        }
        return connectionProperties;
    }
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static int Main(string[] args)
    {
        try
        {
            Hashtable connectionProperties = init(connectionType);
            // Create a connection to the queue manager using the connection
            // properties just defined
            MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties);
            // Set up the options on the queue we wish to open
            int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
            // Now specify the queue that we wish to open,and the open options
            MQQueue system_default_local_queue =
              qMgr.AccessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE", openOptions);
            // Define a WebSphere MQ message, writing some text in UTF format
            MQMessage hello_world = new MQMessage();
            hello_world.WriteUTF("Hello World!");
            // Specify the message options
            MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,
            // same as MQPMO_DEFAULT
            // Put the message on the queue
            system_default_local_queue.Put(hello_world, pmo);

            // Get the message back again
            // First define a WebSphere MQ message buffer to receive the message
            MQMessage retrievedMessage = new MQMessage();
            retrievedMessage.MessageId = hello_world.MessageId;
            // Set the get message options
            MQGetMessageOptions gmo = new MQGetMessageOptions(); //accept the defaults
            //same as MQGMO_DEFAULT
            // Get the message off the queue
            system_default_local_queue.Get(retrievedMessage, gmo);
            // Prove we have the message by displaying the UTF message text
            String msgText = retrievedMessage.ReadUTF();
            Console.WriteLine("The message is: {0}", msgText);
            // Close the queue
            system_default_local_queue.Close();
            // Disconnect from the queue manager
            qMgr.Disconnect();
        }
        //If an error has occurred in the above,try to identify what went wrong.
        //Was it a WebSphere MQ error?
        catch (MQException ex)
        {
            Console.WriteLine("A WebSphere MQ error occurred: {0}", ex.ToString());
        }
        catch (System.Exception ex)
        {
            Console.WriteLine("A System error occurred: {0}", ex.ToString());
        }
        return 0;
    }//end of start
}//end of sample

  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-122182-1-1.html 上篇帖子: IBM As400 数据转换乱码问题的解决 下篇帖子: 9月2号在深圳参加了IBM rational 2008年高峰论坛
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表