Spring集成:Sink中的BeanDefinitionStoreException'input'已在Processor中定义

时间:2019-07-12 10:58:45

标签: spring-cloud-stream

我得到的错误是:org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'input' defined in org.springframework.cloud.stream.messaging.Sink: bean definition with this name already exists - Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.stream.messaging.Processor; factoryMethodName=input; initMethodName=null; destroyMethodName=null

我的接收器和处理器配置为:

@EnableBinding(Source.class)
@Import({TriggerConfig.class, TriggerPropertiesMaxMessagesDefaultOne.class})
public class TimeSourceConfig {

    @Autowired
    private TriggerProperties triggerProperties;

    @PollableSource
    public String publishTime() {
        return new SimpleDateFormat(this.triggerProperties.getDateFormat()).format(new Date());
    }

}

处理器绑定如下:

@EnableBinding(Processor.class)
public class ProcessRedcapPartnerDealers {
...

    @Transformer(inputChannel = Processor.INPUT, outputChannel = Channels.PROCESSOR_PARTNER_DEALERS)
    public List<DealerModel> processPartnerDealerData(){
...
}
}

和接收器绑定是这样的:

@EnableBinding(Sink.class)
public class SinkDataProcessor {
...

@ServiceActivator(inputChannel = Channels.PROCESSOR_PARTNER_DEALERS)
    public void processInboundMessage(@Payload List<DealerModel> dealerModels) {

...

}

}
从我看到的所有联机资源中

看起来配置正确。不知道我在做什么错,但是我抱怨“输入” bean被定义在两个地方。如果我进入Porcessor类扩展其接收器和源,但这不应该导致此问题?有任何想法吗?

1 个答案:

答案 0 :(得分:1)

Processor接口仅扩展了SourceSink

public interface Processor extends Source, Sink {

}
  

但这不应该引起此问题吗?

您不能有两个具有相同名称的绑定。

您将需要使用其他@Input名称创建自己的界面。