Program to create a connection and access IBM MQ 7

我怕爱的太早我们不能终老 提交于 2019-12-11 14:56:59

问题


I have two programs

First Program :

qManager = serverConfig.qMgr;
            queueName=serverConfig.qName;
            this.serverType=serverType;
            //Factory Settings

            MQEnvironment.hostname =serverConfig.server;

            MQEnvironment.port = serverConfig.port;
            //
            MQEnvironment.channel = serverConfig.sChannel;

            MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);//Connection

// Create a connection to the queue manager

            //qMgr = new MQQueueManager(qManager);

Second Program :

                InitialDirContext ctx = null;
                Hashtable environment = new java.util.Hashtable();
                try{
                environment.put(Context.INITIAL_CONTEXT_FACTORY,QUEUE_CONTEXT);
                environment.put(Context.PROVIDER_URL,QUEUE_URL);
                ctx = new InitialDirContext(environment);

In the first program it asks for queue manager name but in the second program it doesn't require Queue Manager name. I need to replace the First program code with the second program.. Can anyone help me on this ..??


回答1:


Your second program is a JMS application and is using JNDI lookup to get connection details.

            environment.put(Context.INITIAL_CONTEXT_FACTORY,QUEUE_CONTEXT);
            environment.put(Context.PROVIDER_URL,QUEUE_URL);

            ctx = new InitialDirContext(environment);    
            connectionFactory = (ConnectionFactory) ctx.lookup(MYCF_LOOKUP_NAME);

QUEUE_CONTEXT is the connection factory name that's being looked up from QUEUE_URL. The QUEUE_CONTEXT will have all the connection details like the queue manager name, channel etc.



来源:https://stackoverflow.com/questions/19681980/program-to-create-a-connection-and-access-ibm-mq-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!