/** * Specify the {@code outputChannel} for the * {@link org.springframework.integration.core.MessageProducer} * @param outputChannel the outputChannel. * @return the spec. * @see MessageProducerSupport#setOutputChannel(MessageChannel) */ public S outputChannel(MessageChannel outputChannel) { this.target.setOutputChannel(outputChannel); return _this(); }
@Override public void setOutputChannel(MessageChannel outputChannel) { super.setOutputChannel(outputChannel); this.listener.setRequestChannel(outputChannel); }
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; MessageChannel outputChannel = messageProducer.getOutputChannel(); if (outputChannel == null) { outputChannel = new DirectChannel(); messageProducer.setOutputChannel(outputChannel); } if (integrationFlowBuilder == null) { integrationFlowBuilder = from(outputChannel); } else { integrationFlowBuilder.channel(outputChannel); } return integrationFlowBuilder.addComponent(messageProducer); }
@Test(expected = MessageDeliveryException.class) public void validateExceptionIfNoErrorChannel() { DirectChannel outChannel = new DirectChannel(); outChannel.subscribe(message -> { throw new RuntimeException("problems"); }); MessageProducerSupport mps = new MessageProducerSupport() { }; mps.setOutputChannel(outChannel); mps.setBeanFactory(this.context); mps.afterPropertiesSet(); mps.start(); mps.sendMessage(new GenericMessage<>("hello")); }
@Test(expected = MessageDeliveryException.class) public void validateExceptionIfSendToErrorChannelFails() { DirectChannel outChannel = new DirectChannel(); outChannel.subscribe(message -> { throw new RuntimeException("problems"); }); PublishSubscribeChannel errorChannel = new PublishSubscribeChannel(); errorChannel.subscribe(message -> { throw new RuntimeException("ooops"); }); MessageProducerSupport mps = new MessageProducerSupport() { }; mps.setOutputChannel(outChannel); mps.setErrorChannel(errorChannel); mps.setBeanFactory(this.context); mps.afterPropertiesSet(); mps.start(); mps.sendMessage(new GenericMessage<>("hello")); }
@Override public void setOutputChannel(MessageChannel outputChannel) { super.setOutputChannel(outputChannel); this.listener.setRequestChannel(outputChannel); }
/** * Specify the {@code outputChannel} for the * {@link org.springframework.integration.core.MessageProducer} * @param outputChannel the outputChannel. * @return the spec. * @see MessageProducerSupport#setOutputChannel(MessageChannel) */ public S outputChannel(MessageChannel outputChannel) { this.target.setOutputChannel(outputChannel); return _this(); }
/** * Specify the {@code outputChannel} for the * {@link org.springframework.integration.core.MessageProducer} * @param outputChannel the outputChannel. * @return the spec. * @see MessageProducerSupport#setOutputChannel(MessageChannel) */ public S outputChannel(MessageChannel outputChannel) { target.setOutputChannel(outputChannel); return _this(); }
@Override public void setOutputChannel(MessageChannel requestChannel) { super.setOutputChannel(requestChannel); this.listener.setRequestChannel(requestChannel); }
@Override public void setOutputChannel(MessageChannel requestChannel) { super.setOutputChannel(requestChannel); this.listener.setRequestChannel(requestChannel); }
/** * Specify the {@code outputChannel} for the * {@link org.springframework.integration.core.MessageProducer} * @param outputChannel the outputChannel. * @return the spec. * @see MessageProducerSupport#setOutputChannel(MessageChannel) */ public S outputChannel(MessageChannel outputChannel) { target.setOutputChannel(outputChannel); return _this(); }
@Test public void validateSuccessfulErrorFlowDoesNotThrowErrors() { this.context.refresh(); DirectChannel outChannel = new DirectChannel(); outChannel.subscribe(message -> { throw new RuntimeException("problems"); }); PublishSubscribeChannel errorChannel = new PublishSubscribeChannel(); SuccessfulErrorService errorService = new SuccessfulErrorService(); ServiceActivatingHandler handler = new ServiceActivatingHandler(errorService); handler.setBeanFactory(this.context); handler.afterPropertiesSet(); errorChannel.subscribe(handler); MessageProducerSupport mps = new MessageProducerSupport() { }; mps.setOutputChannel(outChannel); mps.setErrorChannel(errorChannel); mps.setBeanFactory(this.context); mps.afterPropertiesSet(); mps.start(); Message<?> message = new GenericMessage<>("hello"); mps.sendMessage(message); assertThat(errorService.lastMessage, instanceOf(ErrorMessage.class)); ErrorMessage errorMessage = (ErrorMessage) errorService.lastMessage; assertEquals(MessageDeliveryException.class, errorMessage.getPayload().getClass()); MessageDeliveryException exception = (MessageDeliveryException) errorMessage.getPayload(); assertEquals(message, exception.getFailedMessage()); }
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; MessageChannel outputChannel = messageProducer.getOutputChannel(); if (outputChannel == null) { outputChannel = new DirectChannel(); messageProducer.setOutputChannel(outputChannel); } if (integrationFlowBuilder == null) { integrationFlowBuilder = from(outputChannel); } else { integrationFlowBuilder.channel(outputChannel); } return integrationFlowBuilder.addComponent(messageProducer); }
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, IntegrationFlowBuilder integrationFlowBuilder) { MessageChannel outputChannel = messageProducer.getOutputChannel(); if (outputChannel == null) { outputChannel = new DirectChannel(); messageProducer.setOutputChannel(outputChannel); } if (integrationFlowBuilder == null) { integrationFlowBuilder = from(outputChannel); } else { integrationFlowBuilder.channel(outputChannel); } return integrationFlowBuilder.addComponent(messageProducer); }
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, IntegrationFlowBuilder integrationFlowBuilder) { MessageChannel outputChannel = messageProducer.getOutputChannel(); if (outputChannel == null) { outputChannel = new DirectChannel(); messageProducer.setOutputChannel(outputChannel); } if (integrationFlowBuilder == null) { integrationFlowBuilder = from(outputChannel); } else { integrationFlowBuilder.channel(outputChannel); } return integrationFlowBuilder.addComponent(messageProducer); }