Exemple #1
0
        /// <summary>
        /// Sends the given <see cref="TransportMessageToSend"/> to the input queue specified by <see cref="inputQueueName"/>
        /// using MSMQ
        /// </summary>
        public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
        {
            var recipientPath = MsmqUtil.GetSenderPath(destinationQueueName);

            try
            {
                if (!context.IsTransactional)
                {
                    using (var outputQueue = GetMessageQueue(recipientPath))
                        using (var transaction = new MessageQueueTransaction())
                        {
                            transaction.Begin();
                            outputQueue.Send(message, transaction);
                            transaction.Commit();
                        }
                    return;
                }

                using (var outputQueue = GetMessageQueue(recipientPath))
                {
                    outputQueue.Send(message, GetTransaction(context));
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException(string.Format("An error occurred while attempting to send {0} to {1}",
                                                             message, destinationQueueName), e);
            }
        }
Exemple #2
0
        public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
        {
            var recipientPath = MsmqUtil.GetSenderPath(destinationQueueName);

            if (!context.IsTransactional)
            {
                using (var outputQueue = GetMessageQueue(recipientPath))
                    using (var transaction = new MessageQueueTransaction())
                    {
                        transaction.Begin();
                        outputQueue.Send(message, transaction);
                        transaction.Commit();
                    }
                return;
            }

            using (var outputQueue = GetMessageQueue(recipientPath))
            {
                outputQueue.Send(message, GetTransaction(context));
            }
        }