Autoconfiguration

Dependency

<dependency>
    <groupId>io.pipelite</groupId>
    <artifactId>pipelite-spring-starter</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

@EnablePipelite

The @EnablePipelite annotation activates the entire Pipelite infrastructure in the Spring context. Its flowConfigurations attribute declares the @FlowConfiguration classes that contain the flow definitions:

@SpringBootApplication
@EnablePipelite(flowConfigurations = OrderFlowConfiguration.class)    (1)
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
1 Lists the @FlowConfiguration classes to register. Spring constructs them as beans and FlowConfigurationBeanPostProcessor scans their @DefineFlow methods.

The @FlowConfiguration class defines flows via @DefineFlow methods:

@FlowConfiguration
public class OrderFlowConfiguration {

    private final OrderService orderService;

    public OrderFlowConfiguration(OrderService orderService) {    (1)
        this.orderService = orderService;
    }

    @DefineFlow
    public FlowDefinition orderFlow() {
        return Pipelite.defineFlow("order-flow")
            .fromSource("kafka://orders")
            .process("handle", exchange ->
                orderService.handle(exchange.getInputPayloadAs(Order.class)))
            .toSink("slf4j://orders-log")
            .build();
    }

    @DefineFlow
    public FlowDefinition orderAuditFlow() {
        return Pipelite.defineFlow("order-audit-flow")
            .fromSource("time://audit-tick?period=60000")
            .toSink("slf4j://audit-log")
            .build();
    }
}
1 Standard Spring constructor injection — OrderService must be a Spring-managed bean.

For the complete @FlowConfiguration / @DefineFlow reference, including plain-Java usage and dependency resolution, see FlowConfiguration SPI.

Auto-configured components

@EnablePipelite imports PipeliteConfigurationImportSelector, which registers:

Bean Status Responsibility

PipeliteContext

Active

The framework singleton context, built by PipeliteAutoConfiguration.

FlowConfigurationBeanPostProcessor

Active

Detects @FlowConfiguration beans, invokes @DefineFlow methods, and registers the resulting FlowDefinition instances in PipeliteContext.

PipeliteContextLifecycleManager

Active

Implements SmartLifecycle to start and stop the context in sync with Spring.

PipeliteContextInitializer

Active

Initializes the context with internal factories.

FlowDefinitionRegistrar

Deprecated

Legacy BeanPostProcessor that intercepts FlowDefinition beans. Will be removed in a future major release.

Lifecycle with Spring

PipeliteContextLifecycleManager integrates with the Spring lifecycle:

  • start() → invoked by Spring after the ApplicationContext refresh, once all @FlowConfiguration beans have been processed by FlowConfigurationBeanPostProcessor.

  • stop() → invoked by Spring during orderly shutdown.

Registering multiple flows

Multiple @DefineFlow methods in one class:

@FlowConfiguration
public class AllFlowsConfiguration {

    @DefineFlow
    public FlowDefinition orderFlow() { ... }

    @DefineFlow
    public FlowDefinition paymentFlow() { ... }
}

Multiple @FlowConfiguration classes in @EnablePipelite:

@EnablePipelite(flowConfigurations = {
    OrderFlowConfiguration.class,
    PaymentFlowConfiguration.class,
    AuditFlowConfiguration.class
})

Deprecated: @Bean FlowDefinition pattern

Prior to 1.0.0-SNAPSHOT, flows were declared as @Bean methods returning FlowDefinition and detected by FlowDefinitionRegistrar:

// Deprecated — do not use in new code
@Configuration
@EnablePipelite
public class PipeliteConfig {

    @Bean
    public FlowDefinition myFlow() {
        return Pipelite.defineFlow("my-flow")
            .fromSource("time://tick?period=10000")
            .toSink("slf4j://log")
            .build();
    }
}

Migrate to @FlowConfiguration / @DefineFlow with @EnablePipelite(flowConfigurations = …​). FlowDefinitionRegistrar is @Deprecated and will be removed in a future major release.