Language SDKs
Unmeshed Java SDK
This README will guide you on how to set up Unmeshed credentials, run workers, and get started with the Unmeshed platform using the Java SDK.
Prerequisites
Before running your Java project, make sure you have:
- Java Development Kit (JDK): Java 21 or above.
- Maven or Gradle: For managing dependencies.
- Unmeshed SDK dependency: See your
build.gradleorpom.xml. - Environment Variables:
UNMESHED_AUTH_ID: Your Unmeshed authentication ID.UNMESHED_AUTH_TOKEN: Your Unmeshed authentication token.UNMESHED_ENGINE_HOST: Base URL for the Unmeshed server (defaults tohttp://localhost).UNMESHED_ENGINE_PORT: Port (defaults to8080).
For help generating your Auth ID and Auth Token, see the Creating Client Credentials.
Setup Instructions
- Clone the Repository:
- Run
Main.javato start the example application.
Writing Your Own Worker
-
Check example workers in
io.unmeshed.sdk.samples.workers:ArithmeticWorkerHelloWorldWorker
-
Create a new worker class, or add a new method in an existing worker class.
-
Annotate the method with
@WorkerFunction(name = "<worker_name>"), where<worker_name>is the worker queue name you want to bind to.
Example:
@WorkerFunction supports six parameters:
- For regular Java projects, annotation parameters support direct values.
- For Spring-based projects, annotation parameters support direct values as well as Spring Expression Language (SpEL) where expression fields are available.
| Parameter | Type | Default | Description | When to set |
|---|---|---|---|---|
name | String | Required | Worker function name (queue binding). | Always set this to the worker queue/function name your process step uses. |
namespace | String | "default" | Namespace where this worker function is registered. | Set when your workers run outside the default namespace. |
maxInProgress | int | 10 | Max number of in-progress tasks this worker can handle concurrently. | Increase for higher throughput, reduce to protect downstream systems. |
maxInProgressExpression | String | "" | Expression-based override for concurrency (maxInProgress). In Spring-based projects, this can be provided as a SpEL expression. | Use when concurrency must be configured dynamically at runtime. |
ioThread | boolean | false | Whether execution should run on an IO thread. | Set to true for IO-heavy/non-blocking work; keep false for CPU-heavy or blocking logic. |
workStepNames | String[] | {} | Optional list of step names this worker should serve. If specified, the worker is bound only to those step names. If left empty ({}), workers are registered by name() in the given namespace. | Set when one worker method should only serve selected process step names; leave empty to use normal name() registration in that namespace. |
Using @WorkerFunction annotation in SpringBoot
Reference implementation with Spring Boot worker examples:
Using @WorkerFunction annotation in SpringBoot
Register Inline (Lambda) Workers
You can register lambda workers directly with the client:
Accessing Execution Context
To get additional context such as step ID or process ID inside your worker:
See HelloWorldWorker.java for a concrete example.
Process Management
The SDK provides comprehensive process definition management capabilities. See ProcessManagementExamples.java for a complete working example.
Create a Process Definition
Create a Step Definition
Get Process Definition (Latest or Specific Version)
Get All Process Definitions
Update a Process Definition
Delete Process Definitions
Complete Process Management Example
ProcessManagementExamples.java demonstrates:
- Creating a process definition with steps
- Fetching the latest version of a process
- Retrieving all process definitions
- Updating an existing process definition
- Deleting process definitions
Visit Unmeshed to get started.
Java, Go, Python, and JavaScript are trademarks of their respective owners. Their logos are used for identification purposes only and do not imply endorsement by or affiliation with Unmeshed.