Unmeshed Logo

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.

Java logo

Prerequisites

Before running your Java project, make sure you have:

  1. Java Development Kit (JDK): Java 21 or above.
  2. Maven or Gradle: For managing dependencies.
  3. Unmeshed SDK dependency: See your build.gradle or pom.xml.
  4. 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 to http://localhost).
    • UNMESHED_ENGINE_PORT: Port (defaults to 8080).

For help generating your Auth ID and Auth Token, see the Creating Client Credentials.


Setup Instructions

  1. Clone the Repository:
bash
  1. Run Main.java to start the example application.

Writing Your Own Worker

  1. Check example workers in io.unmeshed.sdk.samples.workers:

    • ArithmeticWorker
    • HelloWorldWorker
  2. Create a new worker class, or add a new method in an existing worker class.

  3. Annotate the method with @WorkerFunction(name = "<worker_name>"), where <worker_name> is the worker queue name you want to bind to.

Example:

java

@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.
ParameterTypeDefaultDescriptionWhen to set
nameStringRequiredWorker function name (queue binding).Always set this to the worker queue/function name your process step uses.
namespaceString"default"Namespace where this worker function is registered.Set when your workers run outside the default namespace.
maxInProgressint10Max number of in-progress tasks this worker can handle concurrently.Increase for higher throughput, reduce to protect downstream systems.
maxInProgressExpressionString""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.
ioThreadbooleanfalseWhether execution should run on an IO thread.Set to true for IO-heavy/non-blocking work; keep false for CPU-heavy or blocking logic.
workStepNamesString[]{}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:

java

Accessing Execution Context

To get additional context such as step ID or process ID inside your worker:

java

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

java

Create a Step Definition

java

Get Process Definition (Latest or Specific Version)

java

Get All Process Definitions

java

Update a Process Definition

java

Delete Process Definitions

java

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.