Beispiel #1
0
        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            var    reader   = new StreamReader(MessageBody.Load(context));
            string testData = reader.ReadToEnd();

            context.LogData("MSMQ input message:", testData);

            // Remote or not?
            if (!string.IsNullOrEmpty(HostName))
            {
                context.LogInfo("Host to connect to: \"{0}\" on port \"{1}\" with channel \"{2}\"", HostName, Port, Channel);
                MQEnvironment.Hostname = HostName;
                MQEnvironment.Port     = Port;
                MQEnvironment.Channel  = Channel;
            }
            MQSeriesHelper.WriteMessage(QueueManager, Queue, testData, context);
        }
Beispiel #2
0
        public override void Execute(Context context)
        {
            _request = MessageBody.Load(context);
            context.LogXmlData("Message", _request, true);

            try
            {
                if (!UseTransactions)
                {
                    _transactionType = MessageQueueTransactionType.None;
                }

                context.LogInfo("MSMQWriteStep about to write data to the queue: {0}", QueuePath);

                var queue = new MessageQueue(MSMQHelper.DeNormalizeQueueName(QueuePath));
                var msg   = new Message();

                if (BodyType == VarEnum.VT_EMPTY)
                {
                    msg.BodyStream = _request;
                }
                else
                {
                    msg.BodyType = (int)BodyType;
                    var formatter = new ActiveXMessageFormatter();
                    formatter.Write(msg, Common.StreamHelper.WriteStreamToString(_request));
                }

                msg.UseDeadLetterQueue = true;

                if (!string.IsNullOrEmpty(CorrelationId))
                {
                    msg.CorrelationId = CorrelationId;
                }
                msg.AppSpecific = AppSpecific;

                queue.Send(msg, MessageLabel, _transactionType);
            }
            finally
            {
                if (null != _request)
                {
                    _request.Close();
                }
            }
        }