Ejemplo n.º 1
0
        protected override IMessageHandler CreateProducerMessageHandler(IProducerDestination destination, IProducerOptions producerProperties, IMessageChannel errorChannel)
        {
            var handler = new BridgeHandler(ApplicationContext)
            {
                OutputChannel = ((SpringIntegrationProducerDestination)destination).Channel
            };

            return(handler);
        }
        protected override IMessageHandler CreateProducerMessageHandler(IProducerDestination destination, IProducerOptions producerProperties, IMessageChannel errorChannel)
        {
            if (producerProperties.HeaderMode == HeaderMode.EmbeddedHeaders)
            {
                throw new InvalidOperationException("The RabbitMQ binder does not support embedded headers since RabbitMQ supports headers natively");
            }

            var extendedProperties = BindingsOptions.GetRabbitProducerOptions(producerProperties.BindingName);
            var prefix             = extendedProperties.Prefix;
            var exchangeName       = destination.Name;
            var destinationName    = string.IsNullOrEmpty(prefix) ? exchangeName : exchangeName[prefix.Length..];
Ejemplo n.º 3
0
 public DefaultProducingMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string destination,
     IMessageChannel target,
     ILifecycle lifecycle,
     IProducerOptions options,
     IProducerDestination producerDestination)
     : base(destination, target, lifecycle)
 {
     this.binder              = binder;
     this.options             = options;
     this.producerDestination = producerDestination;
 }
 public DefaultProducingMessageChannelBinding(
     AbstractMessageChannelBinder binder,
     string destination,
     IMessageChannel target,
     ILifecycle lifecycle,
     IProducerOptions options,
     IProducerDestination producerDestination,
     ILogger logger = null)
     : base(destination, target, lifecycle)
 {
     _binder              = binder;
     _options             = options;
     _producerDestination = producerDestination;
     _logger              = logger;
 }
Ejemplo n.º 5
0
        private void DestroyErrorInfrastructure(IProducerDestination destination)
        {
            var errorChannelName       = GetErrorsBaseName(destination);
            var errorBridgeHandlerName = GetErrorBridgeName(destination);

            if (_destinationRegistry.Lookup(errorChannelName) is ISubscribableChannel channel)
            {
                if (_destinationRegistry.Lookup(errorBridgeHandlerName) is IMessageHandler bridgeHandler)
                {
                    channel.Unsubscribe(bridgeHandler);
                    _destinationRegistry.Deregister(errorBridgeHandlerName);
                }

                _destinationRegistry.Deregister(errorChannelName);
            }
        }
Ejemplo n.º 6
0
        private void DestroyErrorInfrastructure(IProducerDestination destination)
        {
            var errorChannelName       = GetErrorsBaseName(destination);
            var errorBridgeHandlerName = GetErrorBridgeName(destination);

            if (ApplicationContext.GetService <IMessageChannel>(errorChannelName) is ISubscribableChannel channel)
            {
                if (ApplicationContext.GetService <IMessageHandler>(errorBridgeHandlerName) is IMessageHandler bridgeHandler)
                {
                    channel.Unsubscribe(bridgeHandler);
                    ApplicationContext.Deregister(errorBridgeHandlerName);
                }

                ApplicationContext.Deregister(errorChannelName);
            }
        }
Ejemplo n.º 7
0
        private ISubscribableChannel RegisterErrorInfrastructure(IProducerDestination destination)
        {
            var errorChannelName = GetErrorsBaseName(destination);
            ISubscribableChannel errorChannel;
            var errorChannelObject = _destinationRegistry.Lookup(errorChannelName);

            if (errorChannelObject != null)
            {
                if (!(errorChannelObject is ISubscribableChannel))
                {
                    throw new InvalidOperationException("Error channel '" + errorChannelName + "' must be a ISubscribableChannel");
                }

                errorChannel = (ISubscribableChannel)errorChannelObject;
            }
            else
            {
                errorChannel = new PublishSubscribeChannel(ServiceProvider);
                _destinationRegistry.Register(errorChannelName, errorChannel);
            }

            var defaultErrorChannel = (IMessageChannel)_destinationRegistry.Lookup(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME);

            if (defaultErrorChannel != null)
            {
                var errorBridge = new BridgeHandler(ServiceProvider)
                {
                    OutputChannel = defaultErrorChannel
                };
                errorChannel.Subscribe(errorBridge);
                var errorBridgeHandlerName = GetErrorBridgeName(destination);
                _destinationRegistry.Register(errorBridgeHandlerName, errorBridge);
            }

            return(errorChannel);
        }
Ejemplo n.º 8
0
 protected virtual string GetErrorBridgeName(IProducerDestination destination)
 {
     return(GetErrorsBaseName(destination) + ".bridge");
 }
Ejemplo n.º 9
0
 protected virtual string GetErrorsBaseName(IProducerDestination destination)
 {
     return(destination.Name + ".errors");
 }
Ejemplo n.º 10
0
 protected virtual void AfterUnbindProducer(IProducerDestination destination, IProducerOptions producerOptions)
 {
 }
Ejemplo n.º 11
0
 protected abstract IMessageHandler CreateProducerMessageHandler(IProducerDestination destination, IProducerOptions producerProperties, IMessageChannel errorChannel);
Ejemplo n.º 12
0
 protected virtual IMessageHandler CreateProducerMessageHandler(IProducerDestination destination, IProducerOptions producerProperties, IMessageChannel channel, IMessageChannel errorChannel)
 {
     return(CreateProducerMessageHandler(destination, producerProperties, errorChannel));
 }