AMQP 可轮询频道不被识别为可轮询频道



我的 Spring 集成流程在 xml 中定义如下(请注意,我已经删除了开始/结束字符,因为 xml 在我的问题中没有正确显示(:

<int-amqp:channel id="actionInstructionTransformed" message-driven="false"/>
<int-xml:unmarshalling-transformer
        input-channel="actionInstructionXmlValid" output-channel="actionInstructionTransformed"
        unmarshaller="actionInstructionMarshaller" />

我有一个轮询器定义为:

<int:poller id="customPoller" default="true" trigger="customPeriodicTrigger" task-executor="customTaskExecutor" max-messages-per-poll="${poller.maxMessagesPerPoll}" error-channel="drsGatewayPollerError" />
    <int:transactional propagation="REQUIRED" read-only="true" transaction-manager="transactionManager" />
</int:poller>

在 Java 中,我用以下方式定义了我的使用者:

@Transactional(propagation = Propagation.REQUIRED, readOnly = true, value = "transactionManager")
@ServiceActivator(inputChannel = "actionInstructionTransformed", poller = @Poller(value = "customPoller"),
      adviceChain = "actionInstructionRetryAdvice")
public final void processInstruction(final ActionInstruction instruction) 

从文档(http://docs.spring.io/autorepo/docs/spring-integration/4.0.2.RELEASE/reference/html/amqp.html(中,我了解到actionInstruction Transformed应该是可轮询的,因为我添加了消息驱动="false"。

运行我的 Spring Boot 应用程序时,我收到异常:由:java.lang.IllegalStateException:不应为基于注释的端点指定"@Poller",因为"actionInstruction Transformed"是一个可订阅通道(不可轮询(。

我正在使用Spring Boot 1.4.4.RELEASE。

如何强制操作指令转换为可轮询?

也许您没有导入 XML?在这种情况下,框架将为服务激活器输入通道创建一个DirectChannel

这对我来说很好用...

@SpringBootApplication
@ImportResource("context.xml")
public class So42209741Application {
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext context = SpringApplication.run(So42209741Application.class, args);
        context.getBean("pollable", MessageChannel.class).send(new GenericMessage<>("foo"));
        Thread.sleep(10000);
        context.close();
    }
    @ServiceActivator(inputChannel = "pollable", poller = @Poller(fixedDelay = "5000"))
    public void foo(String in) {
        System.out.println(in);
    }
}

上下文.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd">

    <int-amqp:channel id="pollable" message-driven="false" />
</beans>

最新更新