Fluxtion Maven Plugin Quickstart¶
This quickstart demonstrates how to use the fluxtion-maven-plugin
to generate high-performance, Ahead-of-Time (AOT) compiled event processors as part of your standard Maven build cycle.
Overview¶
The fluxtion-maven-plugin integrates Fluxtion's graph building and code generation tools directly into the Maven lifecycle. It scans your project for graph definitions, generates optimized Java source code, and ensures the generated code is compiled into your final artifact.
Architecture and Execution Path¶
The following diagram illustrates how the fluxtion-maven-plugin fits into the developer's execution path, highlighting the separation between build-time generation and runtime execution.
graph TD
subgraph Build [Build Phase - Maven]
S[Source/Config: Java, Spring, YAML] --> M[Maven Build]
M --> P[fluxtion-maven-plugin]
P --> G[Generated AOT Java Source]
G --> C[Maven Compiler]
C --> A[Application Artifact JAR]
subgraph BuildOnly [Build-time Only Dependencies]
GC[Fluxtion Generator Classes]
PD[Plugin Dependencies]
end
GC -.-> P
PD -.-> P
end
subgraph Run [Runtime Phase - JVM]
A --> App[Your Application]
R[Fluxtion Runtime Lib] --> App
end
style BuildOnly fill:#d4a017,fill-opacity:0.1,stroke:#d4a017,stroke-width:2px,stroke-dasharray: 5 5
style Build fill:#01579b,fill-opacity:0.1,stroke:#01579b,stroke-width:2px
style Run fill:#1b5e20,fill-opacity:0.1,stroke:#1b5e20,stroke-width:2px
Key Concepts¶
- Build-time Generation: The plugin executes during the Maven
compilephase, processing your input configurations to generate AOT Java source code. - AOT Source Usage: Generated source is automatically included in the compilation. Your application code can directly reference these generated classes.
- Separation of Concerns: Generator classes and plugin dependencies are only required during the build. They are not needed on the runtime classpath, keeping your application artifact lean.
- Runtime Requirements: At runtime, your application only needs the core Fluxtion runtime library.
Generation is remote and needs an API key
Building a graph (DataFlowBuilder...build(), interpret(), Fluxtion.compile* / compileAot or the fluxtion-maven-plugin) sends the graph model - not your source files - to the hosted Fluxtion generator by default, and needs an API key. Without a key the build stops before sending anything ("Fluxtion API key is not configured"); a rejected key fails with HTTP 401/403. Put the key in ~/.fluxtion/fluxtion.apiKeyFile as apiKey=YOUR_KEY (the first build creates the file). A generated processor runs with fluxtion-runtime alone and makes no network call. How to get a key: Getting an API key (subscribe to "Fluxtion Source Generator" on RapidAPI).
1. Plugin Configuration¶
Declare the Fluxtion public repository and the builder (the plugin itself is on Maven Central):
<repositories>
<repository>
<id>fluxtion-public</id>
<url>https://repo.repsy.io/mvn/fluxtion/fluxtion-public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.telamin.fluxtion</groupId>
<artifactId>fluxtion-builder</artifactId>
<version>1.0.81</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.telamin.fluxtion</groupId>
<artifactId>fluxtion-runtime</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>
Add the fluxtion-maven-plugin to your pom.xml. The scan goal is used here to find graph definitions in your compiled classes.
<plugin>
<groupId>com.telamin.fluxtion</groupId>
<artifactId>fluxtion-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>scan</goal>
</goals>
</execution>
</executions>
</plugin>
2. Define the DataFlow¶
Implement the FluxtionGraphBuilder interface to define your event processing graph. The plugin will discover this implementation during the scan goal.
package com.telamin.fluxtion.example.compile.maven;
import com.telamin.fluxtion.builder.compile.config.FluxtionCompilerConfig;
import com.telamin.fluxtion.builder.compile.config.FluxtionGraphBuilder;
import com.telamin.fluxtion.builder.generation.config.EventProcessorConfig;
import com.telamin.fluxtion.example.compile.aot.node.PriceLadderPublisher;
public class FluxtionBuilder implements FluxtionGraphBuilder {
@Override
public void buildGraph(EventProcessorConfig eventProcessorConfig) {
// Define the nodes in your graph
eventProcessorConfig.addNode(new PriceLadderPublisher());
}
@Override
public void configureGeneration(FluxtionCompilerConfig compilerConfig) {
// Configure the generated class name and package
compilerConfig.setPackageName("com.telamin.fluxtion.example.compile.maven.generated");
compilerConfig.setClassName("PriceLadderProcessorAot");
}
}
3. Run the Build¶
Execute the standard Maven compile command:
mvn compile
During the build, the plugin will:
- Compile your
FluxtionBuilderclass. - Scan the output directory (
target/classes) forFluxtionGraphBuilderimplementations. - Execute the
buildGraphandconfigureGenerationmethods. - Generate the
PriceLadderProcessorAot.javasource file in the configured directory. - Compile the generated source as part of the project.
4. Use the Generated AOT Processor¶
You can now use the generated class in your application. It implements the standard Fluxtion DataFlow interface and any exported services defined in your graph.
import com.telamin.fluxtion.example.compile.maven.generated.PriceLadderProcessorAot;
// ...
PriceLadderProcessorAot processor = new PriceLadderProcessorAot();
processor.init();
processor.start();
// The processor is now ready to handle events or service calls
processor.newPriceLadder(myPriceLadder);
5. Full Example Code¶
The snippets above are complete for the current release. The aot-compiler project in the
Fluxtion Examples repository has not been migrated yet:
it still uses the legacy pre-com.telamin Maven plugin and an older Fluxtion version, so copy the coordinates
from this page rather than from its pom.xml. Its graph definition and generated processor are still
useful as reading:
- FluxtionBuilder.java - Graph definition and generation config.
- PriceLadderProcessorAot.java - Example of the generated AOT source.