Skip to content

Spring Boot

bloge-spring packages BLOGE into a familiar Spring Boot integration. It auto-configures the runtime, discovers operators from the application context, loads .bloge files, and exposes actuator endpoints for graph introspection.

What the starter provides

FeatureDescription
Operator discoveryRegisters Spring beans annotated with @BlogeOperator
Graph loadingCompiles .bloge files from configured classpath locations
GraphEngine beanBuilds the engine with discovered registries, listeners, and interceptors
Actuator endpointsExposes graph inventory and graph details under /actuator/bloge
Optional durable integrationWires runtime stores when bloge-durable and a DataSource are present
Optional observabilityAuto-registers metrics, tracing, and logging components when telemetry libs are available

Quick start

1. Add the dependency

xml
<dependency>
    <groupId>com.leanowtech.bloge</groupId>
    <artifactId>bloge-spring</artifactId>
    <version>${bloge.version}</version>
</dependency>

2. Publish an operator bean

java
@BlogeOperator("FetchUserOperator")
public class FetchUserOperator implements Operator<Map<String, Object>, Map<String, Object>> {
    @Override
    public Map<String, Object> execute(Map<String, Object> input, OperatorContext ctx) {
        String userId = (String) input.get("userId");
        User user = userService.findById(userId);
        return Map.of("id", user.id(), "name", user.name());
    }
}

3. Place DSL files on the classpath

src/main/resources/bloge/order-process.bloge
bloge
graph orderProcess {
  node fetchUser : FetchUserOperator {
    input { userId = ctx.userId }
    timeout = 3s
  }
}

4. Inject and execute

java
@Service
class OrderService {
    private final GraphEngine engine;
    private final List<Graph> graphs;

    OrderService(GraphEngine engine, List<Graph> graphs) {
        this.engine = engine;
        this.graphs = graphs;
    }

    GraphResult processOrder(String userId) {
        Graph graph = graphs.stream()
            .filter(g -> g.name().equals("orderProcess"))
            .findFirst()
            .orElseThrow();

        return engine.execute(graph, new GraphContext(Map.of("userId", userId)));
    }
}

Auto-configured beans

BlogeAutoConfiguration can provide these building blocks automatically:

BeanDescription
OperatorRegistryScans @BlogeOperator beans and registers them
GraphEngineWires interceptors, listeners, and runtime integrations
GraphLoaderCompiles DSL assets
List<Graph>Loads all configured DSL graphs
ArchiveServiceAvailable when durable runtime stores are present
DurableControlPlaneServiceAvailable when durable runtime stores are present

Configuration properties

Core properties

yaml
spring:
  bloge:
    dsl-locations: classpath:bloge/
    hot-reload: false
    default-timeout: 30s
    accessor-mode: method-handle

Durable runtime properties

When bloge-durable is on the classpath, the starter supports routing, archive, replica, and tenant-oriented configuration under spring.bloge.durable.*.

yaml
spring:
  bloge:
    durable:
      data-source-bean: primaryDataSource
      routing:
        mode: TENANT
        tenant-strategy: SEPARATE_DATABASE
        fallback-shard-id: shared
      archive:
        retention: 30d
        batch-size: 500
        policy: MOVE_TO_ARCHIVE

Observability properties

yaml
spring:
  bloge:
    observability:
      metrics:
        enabled: true
        prefix: bloge
      tracing:
        enabled: true
      logging:
        enabled: true

Actuator endpoints

With Spring Boot Actuator on the classpath, BLOGE exposes:

  • GET /actuator/bloge for graph inventory
  • GET /actuator/bloge/{graphName} for graph details

Typical payloads include graph counts, source nodes, terminal nodes, and edge counts, which makes it easier to inspect registered orchestration assets in a running service.

Best practices

  • Keep operator beans focused and side-effect aware.
  • Store DSL graphs under a dedicated classpath:bloge/ folder.
  • Use actuator endpoints for inventory and production sanity checks.
  • Add bloge-durable and bloge-metrics-otel only when the service actually needs those capabilities.

Next steps