Beispiel #1
0
        private void ReceiveMessage(OpenedQueue queue, string messageId, Func <CurrentMessageInformation, bool> messageArrived, Action <CurrentMessageInformation, Exception> messageProcessingCompleted)
        {
            var message = queue.TryGetMessageFromQueue(messageId);

            if (message == null)
            {
                return;
            }

            ProcessMessage(message, queue, null, messageArrived, null, messageProcessingCompleted);
        }
Beispiel #2
0
        public void ReceiveMessageInTransaction(OpenedQueue queue, string messageId, Func <CurrentMessageInformation, bool> messageArrived, Action <CurrentMessageInformation, Exception> messageProcessingCompleted, Action <CurrentMessageInformation> beforeMessageTransactionCommit, Action <CurrentMessageInformation> beforeMessageTransactionRollback)
        {
            using (var tx = _transactionStrategy.Begin())
            {
                var message = queue.TryGetMessageFromQueue(messageId);

                if (message == null)
                {
                    return;// someone else got our message, better luck next time
                }
                ProcessMessage(message, queue, tx, messageArrived, beforeMessageTransactionCommit, beforeMessageTransactionRollback, messageProcessingCompleted);
            }
        }
Beispiel #3
0
        public void ReceiveMessageInTransaction(OpenedQueue queue, string messageId, Func <CurrentMessageInformation, bool> messageArrived, Action <CurrentMessageInformation, Exception> messageProcessingCompleted, Action <CurrentMessageInformation> beforeMessageTransactionCommit)
        {
            var transactionOptions = new TransactionOptions
            {
                IsolationLevel = queueIsolationLevel,
                Timeout        = TransportUtil.GetTransactionTimeout(),
            };

            using (var tx = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
            {
                var message = queue.TryGetMessageFromQueue(messageId);

                if (message == null)
                {
                    return;// someone else got our message, better luck next time
                }
                ProcessMessage(message, queue, tx, messageArrived, beforeMessageTransactionCommit, messageProcessingCompleted);
            }
        }
		protected override void HandlePeekedMessage(OpenedQueue queue, Message message)
		{
			try
			{
				using (var tx = new TransactionScope(TransactionScopeOption.Required, TransportUtil.GetTransactionTimeout()))
				{
					message = queue.TryGetMessageFromQueue(message.Id);
					if (message == null)
						return;

					if ((MessageType) message.AppSpecific == MessageType.LoadBalancerMessageMarker)
					{
						HandleLoadBalancerMessage(queue, message);
					}
				tx.Complete();
				}
			}
			catch (Exception e)
			{
				logger.Error("Fail to process load balanced message properly", e);
			}
		}
Beispiel #5
0
		protected override void HandlePeekedMessage(OpenedQueue queue, Message message)
		{
			try
			{
				using (var tx = new TransactionScope(TransactionScopeOption.Required, TransportUtil.GetTransactionTimeout()))
				{
					message = queue.TryGetMessageFromQueue(message.Id);
					if (message == null)
						return;

					PersistEndpoint(queue, message);

					switch ((MessageType)message.AppSpecific)
					{
						case MessageType.ShutDownMessageMarker:
							//silently cnsume the message
							break;
						case MessageType.LoadBalancerMessageMarker:
							HandleLoadBalancerMessage(queue, message);
							break;
						case MessageType.AdministrativeMessageMarker:
							SendToAllWorkers(message, "Dispatching administrative message from {0} to load balancer {1}");
							break;
						default:
							HandleStandardMessage(queue, message);
							break;
					}
					tx.Complete();
				}
			}
			catch (Exception e)
			{
				logger.Error("Fail to process load balanced message properly", e);
			}
		}
Beispiel #6
0
        public void ReceiveMessageInTransaction(OpenedQueue queue, string messageId, Func<CurrentMessageInformation, bool> messageArrived, Action<CurrentMessageInformation, Exception> messageProcessingCompleted)
        {
            var transactionOptions = new TransactionOptions
            {
                IsolationLevel = queueIsolationLevel,
                Timeout = TransportUtil.GetTransactionTimeout(),
            };
            using (var tx = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
            {
                var message = queue.TryGetMessageFromQueue(messageId);

                if (message == null)
                    return;// someone else got our message, better luck next time

                ProcessMessage(message, queue, tx, messageArrived, messageProcessingCompleted);
            }
        }
        private void ReceiveMessage(OpenedQueue queue, string messageId, Func<CurrentMessageInformation, bool> messageArrived, Action<CurrentMessageInformation, Exception> messageProcessingCompleted)
        {
            var message = queue.TryGetMessageFromQueue(messageId);

            if (message == null)
                return;

            ProcessMessage(message, queue, null, messageArrived, null, null, messageProcessingCompleted);
        }