質問

I have the following xml and I would like to replace this annoying xml with @Configuration class

<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>

and my gateway:

public interface SomeActionGateway {

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

}

I'm already using configuration annotated class for spring-amqp and it just works fine. How can I do the same with Spring Integration configuration?

P.S: I'm using Spring 3.2 and Spring integration 3.0

役に立ちましたか?

解決

I am sorry you find XML configuration "annoying".

We are working on improving the JavaConfig (@Configuration) experience for Spring Integration.

You can currently wire up any endpoint with JavaConfig today, but it's not pretty; endpoints can be wired with a MessageDrivenConsumer (or PollingConsumer) together with the appropriate MessageHandler. You would have to dig into the ConsumerEndpointFactoryBean and the XML parsers for full details; most components require more than one bean definition.

Like I said, we are working on it; we currently have an open Pull Request for a gateway and there is a Java DSL underway in the extensions repo but it is a work in process, as are the Scala and Groovy DSLs.

EDIT:

Spring Integration 4.0 makes it much easier to use @Configuration.

See the recent webinar.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top