Integration with External Services in BPM
During the scoring process, it is often necessary to access external services: credit bureau checks, anti-fraud systems, data verification, and other checks. BPM provides two main mechanisms for such integration.
Integration Methods
| Method | When to Use |
|---|---|
| External Worker Task | Simple checks, polling model, delay is not critical |
| RPC via Kafka | Long operations, asynchronous processing |
1. External Worker Task
What is it
External Worker is a mechanism where an external service "fetches" tasks from BPM, executes them, and returns the result. It works like a task queue: the BPMN process creates a task with a specific topic, and your service periodically polls the platform for new tasks.
How it works
How to use in BPMN diagram
In the BPMN diagram, a Service Task with type "external worker" is used:
- Add a Service Task to the diagram
- Specify the task type: External Worker
- Set the Topic — a unique identifier for your service
Topic Format
Recommended format: {project_code}.{action}.{version}
| Example | Description |
|---|---|
myproject.credit-check.v1 | Credit history check, version 1 |
myproject.fraud-detection.v2 | Anti-fraud check, version 2 |
lending.document-verify.v1 | Document verification |
Data Transfer
- Input data: process variables are automatically passed to the task
- Output data: service result is saved to process variables
Result Types
After task execution, the service must return one of three result types:
| Result | When to Use | What Happens |
|---|---|---|
| success | Task completed successfully | Process continues on the main path |
| bpmnError | Business error (e.g., client failed verification) | Process transitions to error handler (Error Boundary Event) |
| fail | Technical error (service unavailable, timeout) | Task will be retried according to retry settings |
success — use when the check passed and there is a result (positive or negative). For example: "client found in credit bureau database, credit rating 750".
bpmnError — use for business exceptions that should change the process flow. For example: "client is blacklisted" — the process may transition to the rejection branch. When sending bpmnError, an error code is specified that can be handled in the diagram:
- Error Boundary Event without code — catches all bpmnError
- Error Boundary Event with code — catches only errors with the specified code (e.g.,
BLACKLIST,FRAUD_DETECTED)
fail — use for technical failures when the task needs to be retried. For example: "credit bureau service is unavailable" — the system will retry the request later.
When to use
- Simple and fast checks (up to several seconds)
- Service can work in polling mode
- Small delay between task creation and receipt is acceptable
2. Asynchronous Interaction via Kafka
What is it
RPC via Kafka is a Request/Reply pattern where the BPMN process sends a message to a Kafka topic and waits for a response in another topic. This approach is suitable for long operations and asynchronous processing.
How it works
How to use in BPMN diagram
To implement RPC via Kafka in BPMN, two elements are used:
- Send Task — for sending a request to Kafka
- Message Catch Event — for waiting for a response
Correlation ID
The key point is linking request and response through Correlation ID. This is a unique identifier (usually the process instance ID) that:
- Is sent along with the request
- Is returned along with the response
- Allows BPM to understand which process the response is addressed to
When to use
- Long operations (minutes, hours)
- External service works asynchronously
- High load and scalability requirements
Comparison of Approaches
| Criterion | External Worker | Kafka RPC |
|---|---|---|
| Ease of use | Low | Medium |
| Interaction model | Polling | Pub/Sub |
| Latency | Depends on polling interval | Minimal |
| Suitable for | Simple fast checks | Long operations, critical integrations |
| Scalability | Medium | High |
Recommendations for Choosing
Use External Worker if:
- Check executes quickly (seconds)
- Logic is simple and synchronous
- You want minimal configuration
Use Kafka RPC if:
- Operation may take a long time
- Service needs to handle a large flow of requests
- Asynchronous architecture is required