Ejemplo n.º 1
0
        public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
        {
            var queue = MsmqUtil.GetQueuePath(queueEndpoint).Create();

            switch (queueType)
            {
            case QueueType.Standard:
                return(new[]
                {
                    queue,
                    MsmqUtil.OpenOrCreateQueue(GetErrorsQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetSubscriptionQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetDiscardedQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetTimeoutQueuePath(), QueueAccessMode.SendAndReceive, queue),
                });

            case QueueType.LoadBalancer:
                return(new[]
                {
                    queue,
                    MsmqUtil.OpenOrCreateQueue(GetKnownWorkersQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetKnownEndpointsQueuePath(), QueueAccessMode.SendAndReceive, queue),
                });

            default:
                throw new ArgumentOutOfRangeException("queueType", "Can't handle queue type: " + queueType);
            }
        }
Ejemplo n.º 2
0
        public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
        {
            var path = MsmqUtil.GetQueuePath(queueEndpoint);

            return(new[]
            {
                path.Create()
            });
        }
Ejemplo n.º 3
0
 public void BusStarting(IServiceBus bus)
 {
     try
     {
         queueStrategy.InitializeQueue(bus.Endpoint, QueueType.Standard);
     }
     catch (Exception e)
     {
         throw new TransportException(
                   "Could not open queue: " + bus.Endpoint + Environment.NewLine +
                   "Queue path: " + MsmqUtil.GetQueuePath(bus.Endpoint), e);
     }
 }
Ejemplo n.º 4
0
 public static OpenedQueue InitalizeQueue(this Endpoint endpoint)
 {
     try
     {
         return(MsmqUtil.GetQueuePath(endpoint).Open(QueueAccessMode.SendAndReceive));
     }
     catch (Exception e)
     {
         throw new TransportException(
                   "Could not open queue: " + endpoint + Environment.NewLine +
                   "Queue path: " + MsmqUtil.GetQueuePath(endpoint) + Environment.NewLine +
                   "Did you forget to create the queue or disable the queue initialization module?", e);
     }
 }
Ejemplo n.º 5
0
 private MsmqCurrentMessageInformation CreateMessageInformation(OpenedQueue queue, Message message, object[] messages, object msg)
 {
     return(new MsmqCurrentMessageInformation
     {
         MessageId = message.GetMessageId(),
         AllMessages = messages,
         Message = msg,
         Queue = queue,
         TransportMessageId = message.Id,
         Destination = Endpoint.Uri,
         Source = MsmqUtil.GetQueueUri(message.ResponseQueue),
         MsmqMessage = message,
         TransactionType = queue.GetTransactionType()
     });
 }
Ejemplo n.º 6
0
        private OpenedQueue CreateSubscriptionQueue(Uri subscriptionQueueUri, QueueAccessMode accessMode)
        {
            OpenedQueue queue;

            try
            {
                var endpoint = endpointRouter.GetRoutedEndpoint(subscriptionQueueUri);
                queue = MsmqUtil.GetQueuePath(endpoint).Open(accessMode, new XmlMessageFormatter(new[] { typeof(string) }));
            }
            catch (Exception e)
            {
                throw new SubscriptionException("Could not open subscription queue (" + subscriptionQueueUri + ")", e);
            }
            return(queue);
        }
Ejemplo n.º 7
0
 public MessageQueue Create()
 {
     if (IsLocal == false || Exists)
     {
         return(new MessageQueue(queuePath));
     }
     try
     {
         return(MsmqUtil.CreateQueue(queuePath, Transactional ?? true));
     }
     catch (Exception e)
     {
         throw new InvalidAsynchronousStateException("Could not create queue: " + QueueUri, e);
     }
 }
Ejemplo n.º 8
0
        private void SendMessageToQueue(Message message, Endpoint endpoint)
        {
            if (HaveStarted == false)
            {
                throw new TransportException("Cannot send message before transport is started");
            }

            try
            {
                using (var sendQueue = MsmqUtil.GetQueuePath(endpoint).Open(QueueAccessMode.Send))
                {
                    sendQueue.Send(message);
                    logger.DebugFormat("Send message {0} to {1}", message.Label, endpoint);
                }
            }
            catch (Exception e)
            {
                throw new TransactionException("Failed to send message to " + endpoint, e);
            }
        }
Ejemplo n.º 9
0
        private string GetKnownWorkersQueuePath()
        {
            var path = MsmqUtil.GetQueuePath(endpointRouter.GetRoutedEndpoint(endpoint));

            return(path.QueuePath + knownWorkers);
        }
Ejemplo n.º 10
0
        private string GetSubscriptionQueuePath()
        {
            var path = MsmqUtil.GetQueuePath(endpointRouter.GetRoutedEndpoint(endpoint));

            return(path.QueuePath + subscriptions);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the timeout queue path.
        /// </summary>
        /// <returns></returns>
        private string GetTimeoutQueuePath()
        {
            var path = MsmqUtil.GetQueuePath(endpointRouter.GetRoutedEndpoint(endpoint));

            return(path.QueuePath + timeout);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the discarded queue path.
        /// </summary>
        /// <returns></returns>
        private string GetDiscardedQueuePath()
        {
            var path = MsmqUtil.GetQueuePath(endpointRouter.GetRoutedEndpoint(endpoint));

            return(path.QueuePath + discarded);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the errors queue path.
        /// </summary>
        /// <returns></returns>
        private string GetErrorsQueuePath()
        {
            var path = MsmqUtil.GetQueuePath(endpointRouter.GetRoutedEndpoint(endpoint));

            return(path.QueuePath + errors);
        }