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);
            }
        }
 private ConnectionHandler <StompConnection> GetConnection(IEndpointAddress address)
 {
     return(_connectionCache
            .Retrieve(address.Uri,
                      () =>
     {
         var connection = _connectionFactory.Build(address.Uri);
         var connectionHandler = new ConnectionHandlerImpl <StompConnection>(connection);
         return connectionHandler;
     }));
 }
Ejemplo n.º 3
0
        ConnectionHandler <ConnectionImpl> GetConnection([NotNull] AzureServiceBusEndpointAddress address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            _logger.DebugFormat("get connection( address:'{0}' )", address);

            return(_connCache.Retrieve(address.Uri, () =>
            {
                var connection = new ConnectionImpl(address);
                var connectionHandler = new ConnectionHandlerImpl <ConnectionImpl>(connection);

                return connectionHandler;
            }));
        }
Ejemplo n.º 4
0
        ConnectionHandler <RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
        {
            return(_connectionCache.Retrieve(address.Uri, () =>
            {
                ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Retrieve(address.Uri, () =>
                {
                    var configurator = new ConnectionFactoryConfiguratorImpl(address);

                    return configurator.CreateBuilder();
                });

                ConnectionFactory connectionFactory = builder.Build();

                var connection = new RabbitMqConnection(connectionFactory);
                var connectionHandler = new ConnectionHandlerImpl <RabbitMqConnection>(connection);
                return connectionHandler;
            }));
        }
		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);
			}
		}
        ConnectionHandler <RabbitMqConnection> GetConnection(
            Cache <ConnectionFactory, ConnectionHandler <RabbitMqConnection> > cache, IRabbitMqEndpointAddress address)
        {
            ConnectionFactory factory = SanitizeConnectionFactory(address);

            return(cache.Get(factory, _ =>
            {
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Creating RabbitMQ connection: {0}", address.Uri);
                }

                ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Get(factory, __ =>
                {
                    if (_log.IsDebugEnabled)
                    {
                        _log.DebugFormat("Using default configurator for connection: {0}", address.Uri);
                    }

                    var configurator = new ConnectionFactoryConfiguratorImpl(address);

                    return configurator.CreateBuilder();
                });

                ConnectionFactory connectionFactory = builder.Build();

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("RabbitMQ connection created: {0}:{1}/{2}", connectionFactory.HostName,
                                     connectionFactory.Port, connectionFactory.VirtualHost);
                }

                var connection = new RabbitMqConnection(connectionFactory);
                var connectionHandler = new ConnectionHandlerImpl <RabbitMqConnection>(connection);
                return connectionHandler;
            }));
        }
        ConnectionHandler<AzureServiceBusConnection> GetConnection([NotNull] IAzureServiceBusEndpointAddress address)
        {
            if (address == null)
                throw new ArgumentNullException("address");
            _logger.DebugFormat("get connection( address:'{0}' )", address);

            return _connCache.Retrieve(address.Uri, () =>
                {
                    var connection = new AzureServiceBusConnection(address);
                    var connectionHandler = new ConnectionHandlerImpl<AzureServiceBusConnection>(connection);

                    return connectionHandler;
                });
        }
 public SqlOutboundTransport(IEndpointAddress address, ConnectionHandlerImpl <SqlQueueConnection> connectionHandler)
 {
     _connectionHandler = connectionHandler;
     Address            = address;
 }
		ConnectionHandler<RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
		{
			return _connectionCache.Retrieve(address.Uri, () =>
				{
					ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Retrieve(address.Uri, () =>
						{
							var configurator = new ConnectionFactoryConfiguratorImpl(address);

							return configurator.CreateBuilder();
						});

					ConnectionFactory connectionFactory = builder.Build();

					var connection = new RabbitMqConnection(connectionFactory);
					var connectionHandler = new ConnectionHandlerImpl<RabbitMqConnection>(connection);
					return connectionHandler;
				});
		}
Ejemplo n.º 10
0
 private ConnectionHandler<StompConnection> GetConnection(IEndpointAddress address)
 {
     return _connectionCache
         .Retrieve(address.Uri,
                   () =>
                       {
                           var connection = _connectionFactory.Build(address.Uri);
                           var connectionHandler = new ConnectionHandlerImpl<StompConnection>(connection);
                           return connectionHandler;
                       });
 }
		ConnectionHandler<RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
		{
			return _connectionCache.Retrieve(address.Uri, () =>
				{
					var connection = new RabbitMqConnection(address);
					var connectionHandler = new ConnectionHandlerImpl<RabbitMqConnection>(connection);
					return connectionHandler;
				});
		}