Fluent Commerce Logo
Docs

Create Custom Sourcing Criterion

How-to Guide

Author:

Kirill Gaiduk

Changed on:

16 Apr 2026

Key Points

  • Outcome: You’ll extend the Responsive Sourcing Framework with a Custom Criterion and apply it in real Strategies
  • Minimal essentials: Implement the Criterion → register it → expose it in the Setting (auto-generate or manual) → verify behavior
  • Application: Influence Location ranking (exclusion) with domain-specific scoring that fits your business

Steps

Step arrow right iconPreliminary Setup

Start with your own custom module setup.1. Create a custom module.2. Include Sourcing Utilities in your plugin dependencies.Your plugin must have access to its own copy of `util-sourcing` at runtime so it can initialize its own local sourcing registries.You can include it in your project by:
  • Adding it as a dependency in your `pom.xml`
3. Optionally, download the Sourcing Utilities Java source package to review reference implementations.

Step arrow right iconImplement a Custom Sourcing Criterion Function

Create a class that enforces your ranking (exclusion) logic:
  • Implement `SourcingCriterion` (or extend `BaseSourcingCriterion`).
  • (When extending `BaseSourcingCriterion`) Put computation in `execute(CriterionContext ctx)`.
  • (If needed) Parse configuration in `parseParams(JsonNode params)`.
  • (Optional) Override `normalize(min, max, rating)` when your metric is “lower is better” (e.g., distance).

Step arrow right iconIntroduce Custom Sourcing Rules

Introduce custom versions of the Sourcing Rules that will execute your sourcing logic inside your plugin.1. Copy the reference Sourcing Rule implementation:2. Rename the class3. Register your custom Sourcing Condition or Criterion inside the Rule class4. Replace the reference Rule in your Workflow configuration with your custom Rule

Step arrow right iconExpose the Criterion Schema

Create (or update the existing) the Setting `fc.rubix.order.sourcing.criteria.custom` with your new Criterion schema.

Step arrow right iconVerify the Criterion Behavior

  • Use the Sourcing Profile GraphQL API to add the new Criterion to a Sourcing Strategy. 
  • Test against different Sourcing Requests and confirm the expected outcomes.