public IInboundTransport BuildInbound(ITransportSettings settings)
        {
            try
            {
                var msmqEndpointAddress = new MsmqEndpointAddress(settings.Address.Uri, settings.Transactional);
                var msmqSettings = GetTransportSettings(settings, msmqEndpointAddress);

                IMsmqEndpointAddress transportAddress = msmqSettings.MsmqAddress();

                if (transportAddress.IsLocal)
                {
                    ValidateLocalTransport(msmqSettings);

                    PurgeExistingMessagesIfRequested(msmqSettings);
                }

                var connection = new MessageQueueConnection(transportAddress, QueueAccessMode.Receive);
                var connectionHandler = new ConnectionHandlerImpl<MessageQueueConnection>(connection);

                if (msmqSettings.Transactional)
                    return new TransactionalInboundMsmqTransport(transportAddress, connectionHandler,
                        msmqSettings.TransactionTimeout, msmqSettings.IsolationLevel);

                return new NonTransactionalInboundMsmqTransport(transportAddress, connectionHandler);
            }
            catch (Exception ex)
            {
                throw new TransportException(settings.Address.Uri, "Failed to create MSMQ inbound transport", ex);
            }
        }
Esempio n. 2
0
        public IOutboundTransport BuildOutbound(ITransportSettings settings)
        {
            try
            {
                var msmqEndpointAddress        = new MsmqEndpointAddress(settings.Address.Uri, settings.Transactional);
                TransportSettings msmqSettings = GetTransportSettings(settings, msmqEndpointAddress);

                IMsmqEndpointAddress transportAddress = msmqSettings.MsmqAddress();

                if (transportAddress.IsLocal)
                {
                    ValidateLocalTransport(msmqSettings);
                }

                var connection        = new MessageQueueConnection(transportAddress, QueueAccessMode.Send);
                var connectionHandler = new ConnectionHandlerImpl <MessageQueueConnection>(connection);

                if (msmqSettings.Transactional)
                {
                    return(new TransactionalOutboundMsmqTransport(transportAddress, connectionHandler));
                }

                return(new NonTransactionalOutboundMsmqTransport(transportAddress, connectionHandler));
            }
            catch (Exception ex)
            {
                throw new TransportException(settings.Address.Uri, "Failed to create MSMQ outbound transport", ex);
            }
        }
Esempio n. 3
0
        public IInboundTransport BuildInbound(ITransportSettings settings)
        {
            try
            {
                var msmqEndpointAddress        = new MsmqEndpointAddress(settings.Address.Uri, settings.Transactional);
                TransportSettings msmqSettings = GetTransportSettings(settings, msmqEndpointAddress);

                IMsmqEndpointAddress transportAddress = msmqSettings.MsmqAddress();

                if (transportAddress.IsLocal)
                {
                    ValidateLocalTransport(msmqSettings);

                    PurgeExistingMessagesIfRequested(msmqSettings);
                }

                var connection        = new MessageQueueConnection(transportAddress, QueueAccessMode.Receive);
                var connectionHandler = new ConnectionHandlerImpl <MessageQueueConnection>(connection);

                if (msmqSettings.Transactional)
                {
                    return(new TransactionalInboundMsmqTransport(transportAddress, connectionHandler,
                                                                 msmqSettings.TransactionTimeout, msmqSettings.IsolationLevel));
                }

                return(new NonTransactionalInboundMsmqTransport(transportAddress, connectionHandler));
            }
            catch (Exception ex)
            {
                throw new TransportException(settings.Address.Uri, "Failed to create MSMQ inbound transport", ex);
            }
        }
		void Dispose(bool disposing)
		{
			if (_disposed) return;
			if (disposing)
			{
				_connection.Dispose();
				_connection = null;
			}

			_disposed = true;
		}
		public IOutboundTransport BuildOutbound(ITransportSettings settings)
		{
			try
			{
				ITransportSettings msmqSettings = new TransportSettings(new MsmqEndpointAddress(settings.Address.Uri), settings);

				IMsmqEndpointAddress transportAddress = msmqSettings.MsmqAddress();

				if (transportAddress.IsLocal)
				{
					ValidateLocalTransport(msmqSettings);
				}

				var connection = new MessageQueueConnection(transportAddress, QueueAccessMode.Send);
				var connectionHandler = new ConnectionHandlerImpl<MessageQueueConnection>(connection);

				return new NonTransactionalOutboundMsmqTransport(transportAddress, connectionHandler);
			}
			catch (Exception ex)
			{
				throw new TransportException(settings.Address.Uri, "Failed to create MSMQ outbound transport", ex);
			}
		}
		protected OutboundMsmqTransport(IMsmqEndpointAddress address)
		{
			_address = address;
			_connection = new MessageQueueConnection(address, QueueAccessMode.Send);
		}