Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@EnableIntegration annotation purpose

I migrate project from XML Spring Integration configuration to Java DSL. I prepared some integration tests beforehand. So I can do the migration safely step-by-step.

At some point after moving this XML connector definition

<int:publish-subscribe-channel id="upstreamAckChannel" />

to Java Spring Configuration

@Bean
public PublishSubscribeChannel upstreamAckChannel() {
    return MessageChannels.publishSubscribe().get();
}

my integration flow stopped resend test messages to my tests.

After some time and experiments I realized that my Spring Java configuration must have @EnableIntegration annotation together with usual Spring @Configuration annotation for properly work.

The question is what is @EnableIntegration annotation semantic? When I can not use it and when I must use?

I could find only this small Configuration paragraph in official reference manual. Unfortunately, description isn't clear.

like image 348
Andriy Kryvtsun Avatar asked Feb 25 '16 17:02

Andriy Kryvtsun


People also ask

Why do we use Spring Integration?

Spring Integration provides a wide selection of mechanisms to communicate with external systems. Channel adapters are one such mechanism used for one-way integration (send or receive). And gateways are used for request/reply scenarios (inbound or outbound). Apache Camel is an alternative that is widely used.

What is ServiceActivator annotation?

The Service Activator is any POJO that defines the @ServiceActivator annotation on a given method. This allows us to execute any method on our POJO when a message is received from an inbound channel, and it allows us to write messages to an outward channel.

What is Poller in Spring Integration?

PollableChannel interface (such as a QueueChannel ) produces an instance of PollingConsumer . Polling consumers let Spring Integration components actively poll for Messages rather than process messages in an event-driven manner. They represent a critical cross-cutting concern in many messaging scenarios.

What is a service activator?

The service activator is the endpoint type for connecting any Spring-managed object to an input channel so that it may play the role of a service. If the service produces output, it may also be connected to an output channel.


1 Answers

The PublishSubscribeChannel class exists inside of the Spring Integration project. The @EnableIntegration annotation is used to adopt a default configuration for Spring Integration, so typically when using Spring Integration you'll want to add it (unless you're using a piece of Spring Integration that doesn't require a context--unlikely). The only time you might want to forego it is if you want to do your own configuration from scratch.

like image 124
kondrak Avatar answered Oct 18 '22 06:10

kondrak