Example #1
0
		public override void Send(ISendContext context)
		{
			GuardAgainstDisposed();

			LoopbackMessage message = null;
			try
			{
				message = new LoopbackMessage();

				if (context.ExpirationTime.HasValue)
				{
					message.ExpirationTime = context.ExpirationTime.Value;
				}

				context.SerializeTo(message.Body);
				message.ContentType = context.ContentType;

				lock (_messageLock)
				{
					GuardAgainstDisposed();

					_messages.AddLast(message);
				}
			}
			catch
			{
				if(message != null)
					message.Dispose();

				throw;
			}

			_messageReady.Set();
		}
        public void Send(ISendContext context)
        {
            GuardAgainstDisposed();

            LoopbackMessage message = null;
            try
            {
                message = new LoopbackMessage();

                if (context.ExpirationTime.HasValue)
                {
                    message.ExpirationTime = context.ExpirationTime.Value;
                }

                context.SerializeTo(message.Body);
                message.ContentType = context.ContentType;
                message.OriginalMessageId = context.OriginalMessageId;

                if (!Monitor.TryEnter(_messageWriteLock, _deadlockTimeout))
                    throw new Exception("Deadlock detected!");

                try
                {
                    GuardAgainstDisposed();

                    _messages.AddLast(message);
                }
                finally
                {
                    Monitor.Exit(_messageWriteLock);
                }

                Address.LogSent(message.MessageId, context.MessageType);
            }
            catch
            {
                if (message != null)
                    message.Dispose();

                throw;
            }

            _messageReady.Set();
        }
        public void Send(ISendContext context)
        {
            GuardAgainstDisposed();

            LoopbackMessage message = null;
            try
            {
                message = new LoopbackMessage();

                if (context.ExpirationTime.HasValue)
                {
                    message.ExpirationTime = context.ExpirationTime.Value;
                }

                context.SerializeTo(message.Body);
                message.ContentType = context.ContentType;

                lock (_messageLock)
                {
                    GuardAgainstDisposed();

                    _messages.AddLast(message);
                }

                if (SpecialLoggers.Messages.IsInfoEnabled)
                    SpecialLoggers.Messages.InfoFormat("SEND:{0}:{1}:{2}", Address, context.MessageType,
                        message.MessageId);
            }
            catch
            {
                if (message != null)
                    message.Dispose();

                throw;
            }

            _messageReady.Set();
        }