示例#1
0
 public void ListenForCbcRequests()
 {
     try{
         _xffReadFactory    = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
         _connectionFactory = _xffReadFactory.CreateConnectionFactory();
         _connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, CBCApplicationConfigurationdetails.RequestConnection);
         _connectionFactory.SetIntProperty(XMSC.WMQ_PORT, CBCApplicationConfigurationdetails.RequestPort);
         _connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, CBCApplicationConfigurationdetails.RequestChannel);
         _connectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
         _connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, CBCApplicationConfigurationdetails.RequestManger);
         _connectionFactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
         _connectionFactory.SetStringProperty(XMSC.WMQ_PROVIDER_VERSION, MQConfigurationSettings.WMQ_PROVIDER_VERSION);
         _mqConnection      = _connectionFactory.CreateConnection();
         _mqSession         = _mqConnection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
         _mqDestination     = _mqSession.CreateQueue(string.Format("queue://{0}/{1}", CBCApplicationConfigurationdetails.RequestManger, CBCApplicationConfigurationdetails.RequestQueueName));
         _mqMessageConsumer = _mqSession.CreateConsumer(_mqDestination);
         MessageListener ml = OnMessage;
         _mqMessageConsumer.MessageListener = ml;
         _mqConnection.Start();
         //Thread.Sleep(100000);
     }
     catch (Exception exception) {
         FdrCommon.LogEvent(exception, EventLogEntryType.Error);
     }
 }
示例#2
0
        public MQSrMessageQueue()
        {
            XMSFactoryFactory  xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
            IConnectionFactory cf  = xff.CreateConnectionFactory();

            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "ICEKOPAS18");
            cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
            cf.SetStringProperty(XMSC.WMQ_CHANNEL, "SYSTEM.DEF.SVRCONN");
            cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "FI.CADS");
            cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_DIRECT_HTTP);
            cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V2);

            //cf.SetStringProperty(XMSC.USERID, "mqm");
            //cf.SetStringProperty(XMSC.PASSWORD, "mqm");

            IConnection conn = cf.CreateConnection();

            Console.WriteLine("connection created");
            ISession sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);

            //IDestination dest = sess.CreateQueue("DOX.APYMT.ESB.SSK.RPO.02");
            //IMessageConsumer consumer = sess.CreateConsumer(dest);
            //MessageListener ml = new MessageListener(OnMessage);
            //consumer.MessageListener = ml;
            conn.Start();
            Console.WriteLine("Consumer started");
        }
 public void RegisterListener()
 {
     try
     {
         XMSFactoryFactory  xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
         IConnectionFactory cf  = xff.CreateConnectionFactory();
         cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "localhost");
         cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
         cf.SetStringProperty(XMSC.WMQ_CHANNEL, "MY.SVRCONN");
         cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
         cf.SetStringProperty(XMSC.USERID, "userid");
         cf.SetStringProperty(XMSC.PASSWORD, "password");
         cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM1");
         IConnection conn = cf.CreateConnection();
         Console.WriteLine("connection created");
         ISession         sess     = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
         IDestination     dest     = sess.CreateQueue(queue);
         IMessageConsumer consumer = sess.CreateConsumer(dest);
         MessageListener  ml       = new MessageListener(onMessage);
         consumer.MessageListener = ml;
         conn.Start();
         Console.WriteLine("Consumer started");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
示例#4
0
        public IConnectionFactory CreateMQConnectionFactoryWMQ(String hostName, int portNumber, String channelName, String queueManagerName)
        {
            XMSFactoryFactory  factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
            IConnectionFactory cf      = factory.CreateConnectionFactory();

            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, hostName);
            cf.SetIntProperty(XMSC.WMQ_PORT, portNumber);
            // For .NET only (Java JMS is okay using WMQ_CM_CLIENT): managed connections to WMQ (WMQ_CM_CLIENT) will not support SSL connections, but these might be supported by using an unmanaged connection (WMQ_CM_CLIENT_UNMANAGED). Refer to the WebSphere MQ Using .NET manual for accurate information.
            // WebSphere MQ configures a CHLAUTH record by default in WebSphere MQ Version 7.1 and later that blocks all MQ admins from connecting as a client to the queue manager. The following error in the MQ error logs would be seen for this scenario:
            // by default is XMSC.WMQ_CM_CLIENT; however, connection exception due to code 2035
            cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED);
            cf.SetStringProperty(XMSC.WMQ_CHANNEL, channelName);
            cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, queueManagerName);
            return(cf);
        }
    public void Setup()
    {
        XMSFactoryFactory  xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
        IConnectionFactory cf  = xff.CreateConnectionFactory();

        cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "10.87.188.156(7111)");
        cf.SetIntProperty(XMSC.WMQ_PORT, 7111);
        cf.SetStringProperty(XMSC.WMQ_CHANNEL, "QMEIGS1.CRM.SVRCONN");
        cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
        cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QMEIGS1");
        cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
        IConnection conn = cf.CreateConnection();

        Console.WriteLine("connection created");
        ISession         sess     = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
        IDestination     dest     = sess.CreateQueue("DOX.APYMT.ESB.SSK.RPO.02");
        IMessageConsumer consumer = sess.CreateConsumer(dest);
        MessageListener  ml       = new MessageListener(OnMessage);

        consumer.MessageListener = ml;
        conn.Start();
        Console.WriteLine("Consumer started");
    }
        public void Setup()
        {
            XMSFactoryFactory  xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
            IConnectionFactory cf  = xff.CreateConnectionFactory();

            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "localhost");
            cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
            cf.SetStringProperty(XMSC.WMQ_CHANNEL, "CLIENT");
            cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
            cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM_LOCAL");
            cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
            IConnection conn = cf.CreateConnection();

            Console.WriteLine("connection created");
            ISession         sess     = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
            IDestination     dest     = sess.CreateQueue("queue://q");
            IMessageConsumer consumer = sess.CreateConsumer(dest);
            MessageListener  ml       = new MessageListener(OnMessage);

            consumer.MessageListener = ml;
            conn.Start();
            Console.WriteLine("Consumer started");
        }
示例#7
0
        public void ListenMasterLocalFilesRequests()
        {
            _xffReadFactory    = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
            _connectionFactory = _xffReadFactory.CreateConnectionFactory();
            _connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, LMApplicationConfigurationdetails.RequestConnection);
            _connectionFactory.SetIntProperty(XMSC.WMQ_PORT, LMApplicationConfigurationdetails.RequestPort);
            _connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, LMApplicationConfigurationdetails.RequestChannel);
            _connectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
            _connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, LMApplicationConfigurationdetails.RequestManger);
            _connectionFactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
            _connectionFactory.SetStringProperty(XMSC.WMQ_PROVIDER_VERSION, MQConfigurationSettings.WMQ_PROVIDER_VERSION);
            _mqConnection  = _connectionFactory.CreateConnection();
            _newSesstion   = _mqConnection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
            _mqDestination =
                _newSesstion.CreateQueue(string.Format("queue://{0}/{1}",
                                                       LMApplicationConfigurationdetails.RequestManger, LMApplicationConfigurationdetails.RequestQueueName));
            _mqMessageConsumer = _newSesstion.CreateConsumer(_mqDestination);
            MessageListener ml = OnFilesReceived;

            _mqMessageConsumer.MessageListener = ml;
            _mqConnection.Start();
            //Thread.Sleep(int.MaxValue);
        }
示例#8
0
        private void PublishMessageXMS()
        {
            // option 2: XMS
            // NOTE: in MQ, Topic --> Object Authorities --> Manage Authority Records --> Specific Profiles, make sure the users/groups (using the XMS API calls) have the proper permissions, eg. Publish, Subscribe and etc.
            XMSFactoryFactory  ff        = null;
            IConnectionFactory cf        = null;
            IConnection        conn      = null;
            ISession           sess      = null;
            IDestination       dest      = null;
            IMessageProducer   prod      = null;
            ITextMessage       tmsg      = null;
            string             topicName = txQName.Text.ToString();

            try
            {
                ff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
                cf = ff.CreateConnectionFactory();
                cf.SetStringProperty(XMSC.WMQ_HOST_NAME, txHost.Text.ToString());
                int portNo = 0;
                Int32.TryParse(txPort.Text.ToString(), out portNo);
                cf.SetIntProperty(XMSC.WMQ_PORT, portNo);
                cf.SetStringProperty(XMSC.WMQ_CHANNEL, txQChannel.Text.ToString());
                cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED); // default is XMSC.WMQ_CM_CLIENT, it is managed - using the same language; if need to access different platform, use unmanaged
                cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, txQMgr.Text.ToString());

                /*
                 * MessageBox.Show("Host:" + cf.GetStringProperty(XMSC.WMQ_HOST_NAME) + Environment.NewLine +
                 *  "Port:" + cf.GetIntProperty(XMSC.WMQ_PORT) + Environment.NewLine +
                 *  "Queue Manager:" + cf.GetStringProperty(XMSC.WMQ_QUEUE_MANAGER) + Environment.NewLine +
                 *  "Channel:" + cf.GetStringProperty(XMSC.WMQ_CHANNEL) + Environment.NewLine +
                 *  "Topic:" + topicName + Environment.NewLine);
                 */

                conn = cf.CreateConnection();
                sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
                // MessageBox.Show("Session created.");
                dest = sess.CreateTopic(topicName);
                // dest.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_MQ); // exclude RFH2 header since amqchange.exe cannot handle
                // MessageBox.Show("Destination created as Topic.");
                prod = sess.CreateProducer(dest);
                // MessageBox.Show("Message Producer created.");

                conn.Start();
                // MessageBox.Show("Connection started.");
                tmsg = sess.CreateTextMessage(txMessage.Text.ToString());

                prod.Send(tmsg);
                MessageBox.Show("Message " + tmsg.Text.Length + " sent to " + topicName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + ex.Source + Environment.NewLine + ex.GetBaseException());
            }
            finally
            {
                if (prod != null)
                {
                    prod.Close();
                }
                if (dest != null)
                {
                    dest.Dispose();
                }
                if (sess != null)
                {
                    sess.Close();
                    sess.Dispose();
                }
                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }