Search in sources :

Example 1 with SpringIntegrationConsumerDestination

use of org.springframework.cloud.stream.binder.test.TestChannelBinderProvisioner.SpringIntegrationConsumerDestination in project spring-cloud-stream by spring-cloud.

the class TestChannelBinder method createConsumerEndpoint.

@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group, ConsumerProperties properties) throws Exception {
    ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy();
    SubscribableChannel siBinderInputChannel = ((SpringIntegrationConsumerDestination) destination).getChannel();
    IntegrationMessageListeningContainer messageListenerContainer = new IntegrationMessageListeningContainer();
    IntegrationBinderInboundChannelAdapter adapter = new IntegrationBinderInboundChannelAdapter(messageListenerContainer);
    String groupName = StringUtils.hasText(group) ? group : "anonymous";
    ErrorInfrastructure errorInfrastructure = registerErrorInfrastructure(destination, groupName, properties);
    if (properties.getMaxAttempts() > 1) {
        adapter.setRetryTemplate(buildRetryTemplate(properties));
        adapter.setRecoveryCallback(errorInfrastructure.getRecoverer());
    } else {
        adapter.setErrorMessageStrategy(errorMessageStrategy);
        adapter.setErrorChannel(errorInfrastructure.getErrorChannel());
    }
    siBinderInputChannel.subscribe(messageListenerContainer);
    return adapter;
}
Also used : ErrorMessageStrategy(org.springframework.integration.support.ErrorMessageStrategy) DefaultErrorMessageStrategy(org.springframework.integration.support.DefaultErrorMessageStrategy) SpringIntegrationConsumerDestination(org.springframework.cloud.stream.binder.test.TestChannelBinderProvisioner.SpringIntegrationConsumerDestination) DefaultErrorMessageStrategy(org.springframework.integration.support.DefaultErrorMessageStrategy) SubscribableChannel(org.springframework.messaging.SubscribableChannel)

Aggregations

SpringIntegrationConsumerDestination (org.springframework.cloud.stream.binder.test.TestChannelBinderProvisioner.SpringIntegrationConsumerDestination)1 DefaultErrorMessageStrategy (org.springframework.integration.support.DefaultErrorMessageStrategy)1 ErrorMessageStrategy (org.springframework.integration.support.ErrorMessageStrategy)1 SubscribableChannel (org.springframework.messaging.SubscribableChannel)1