【问题标题】:Annotated Configuration usage with Spring Integration使用 Spring Integration 使用带注释的配置
【发布时间】:2014-03-19 01:16:04
【问题描述】:

我有以下 xml,我想用 @Configuration 类替换这个烦人的 xml

<int:gateway id="someActionGateway "
        service-interface="x.y.z.SomeActionGateway"
        default-request-channel="some-action-channel-raw" />

 <int:channel id="some-action-channel-raw" />

 <int:header-enricher input-channel="some-action-channel-raw" output-channel="some-action-to-json-channel">
        <int:header name="someAction" value="sendSomething"/>
 </int:header-enricher>

    <int:channel id="some-action-to-json-channel" />

    <int:object-to-json-transformer
        input-channel="some-action-to-json-channel" output-channel="some-action-outbound-channel"
        content-type="text/x-json" />

    <int:channel id="some-action-outbound-channel" />

    <int-amqp:outbound-channel-adapter
        channel="some-action-outbound-channel" exchange-name="some-action-exchange"
        routing-key="someAction.routing.key" amqp-template="amqpTemplate"
        mapped-request-headers="*">
    </int-amqp:outbound-channel-adapter>

    <rabbit:direct-exchange name="some-action-exchange"
        auto-delete="false" durable="true">
        <rabbit:bindings>
            <rabbit:binding queue="some-action-queue" key="someAction.routing.key" />
        </rabbit:bindings>
    </rabbit:direct-exchange>

和我的网关:

public interface SomeActionGateway {

    @Gateway
    public void sendSomething(@Payload SomeDto dto);

}

我已经在为 spring-amqp 使用配置注释类,它工作得很好。 我怎样才能对 Spring Integration 配置做同样的事情?

P.S:我正在使用 Spring 3.2 和 Spring integration 3.0

【问题讨论】:

    标签: spring rabbitmq spring-integration spring-amqp


    【解决方案1】:

    很抱歉您发现 XML 配置“烦人”。

    我们正在努力改进 Spring Integration 的 JavaConfig (@Configuration) 体验。

    您现在可以使用 JavaConfig 连接任何端点,但这并不漂亮;端点可以与MessageDrivenConsumer(或PollingConsumer)以及适当的MessageHandler 一起连接。您必须深入研究ConsumerEndpointFactoryBean 和 XML 解析器以获取完整的详细信息;大多数组件需要多个 bean 定义。

    就像我说的,我们正在努力;我们目前有一个开放的Pull Request 用于网关,还有一个 Java DSL 正在进行中in the extensions repo 但它正在开发中,Scala 和 Groovy DSL 也是如此。

    编辑:

    Spring Integration 4.0 让@Configuration 的使用变得更加容易。

    查看最近的webinar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      相关资源
      最近更新 更多