protected virtual AbstractEndpoint CreateEndpoint(IMessageHandler handler, MethodInfo method, List <Attribute> annotations) { AbstractEndpoint endpoint = null; var inputChannelName = MessagingAttributeUtils.ResolveAttribute <string>(annotations, InputChannelProperty); if (!string.IsNullOrEmpty(inputChannelName)) { IMessageChannel inputChannel; try { inputChannel = ChannelResolver.ResolveDestination(inputChannelName); if (inputChannel == null) { inputChannel = new DirectChannel(ApplicationContext, inputChannelName); ApplicationContext.Register(inputChannelName, inputChannel); } } catch (DestinationResolutionException) { inputChannel = new DirectChannel(ApplicationContext, inputChannelName); ApplicationContext.Register(inputChannelName, inputChannel); } endpoint = DoCreateEndpoint(handler, inputChannel, annotations); } return(endpoint); }
private IMessageChannel ResolveErrorChannel(Exception exception) { var actualThrowable = exception; if (exception is MessagingExceptionWrapperException) { actualThrowable = exception.InnerException; } var failedMessage = (actualThrowable is MessagingException) ? ((MessagingException)actualThrowable).FailedMessage : null; if (DefaultErrorChannel == null && ChannelResolver != null) { Channel = ChannelResolver.ResolveDestination(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME); } if (failedMessage == null || failedMessage.Headers.ErrorChannel == null) { return(DefaultErrorChannel); } var errorChannelHeader = failedMessage.Headers.ErrorChannel; if (errorChannelHeader is IMessageChannel) { return((IMessageChannel)errorChannelHeader); } if (!(errorChannelHeader is string)) { throw new ArgumentException("Unsupported error channel header type. Expected IMessageChannel or String, but actual type is [" + errorChannelHeader.GetType() + "]"); } if (ChannelResolver != null) { return(ChannelResolver.ResolveDestination((string)errorChannelHeader)); // NOSONAR not null } else { return(null); } }