예제 #1
0
        private void InitConnectionFactory()
        {
            var ff = JmsFactoryFactory.getInstance(JmsConstants.WMQ_PROVIDER);

            cf = ff.createConnectionFactory();

            cf.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
            cf.setStringProperty(CommonConstants.WMQ_HOST_NAME, hostName);
            cf.setIntProperty(CommonConstants.WMQ_PORT, port);
            cf.setStringProperty(CommonConstants.WMQ_CHANNEL, channel);
            cf.setStringProperty(CommonConstants.WMQ_QUEUE_MANAGER, qManager);
            cf.setIntProperty(CommonConstants.WMQ_CCSID, 437);
            cf.setStringProperty(CommonConstants.USERID, appUser);
            cf.setStringProperty(CommonConstants.PASSWORD, appPassword);
            cf.setIntProperty(CommonConstants.JMS_PRIORITY, 9);
            cf.setIntProperty(CommonConstants.WMQ_PRIORITY, 9);
        }
예제 #2
0
        public string[] ReceiveMessages()
        {
            List <string> messages = new List <string>();

            try
            {
                if (cf == null)
                {
                    InitConnectionFactory();
                }

                using (var context = cf.createContext())
                {
                    var queue = context.createQueue($"queue:///{resultQName}");

                    using (var consumer = context.createConsumer(queue))
                    {
                        var message = consumer.receive(timeout);

                        while (message != null)
                        {
                            var body = message?.getBody(typeof(String)) as string;
                            messages.Add(body);

                            message = consumer.receive(timeout);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.ErrorHelper.WriteToLog("EisppService.ReceiveMessages", ex);
            }
            finally
            {
                cf = null;
            }

            return(messages.ToArray());
        }