Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update spring zeebe guide #4072

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions docs/guides/getting-started-java-spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ For example, in this guide we will outline a BPMN model to receive a payment req

![example BPMN model to receive a payment request, prepare a transaction, charge a credit card, and execute a payment](./img/prepare-transaction-example.png)

:::note
While stepping through this guide, you can visit our [sample repository](https://github.com/camunda/camunda-8-get-started-spring/blob/main/src/main/java/io/camunda/demo/process_payments/ChargeCreditCardWorker.java) with the completed code to check your work.
:::

<SmPrereqs/>

## Step 1: Install Camunda 8 Self-Managed
Expand Down Expand Up @@ -202,7 +206,6 @@ import io.camunda.zeebe.spring.client.annotation.Deployment;

```java
@SpringBootApplication
@Deployment(resources = "classpath:process-payments.bpmn")
public class ProcessPaymentsApplication implements CommandLineRunner {

private static final Logger LOG = LoggerFactory.getLogger(ProcessPaymentsApplication.class);
Expand All @@ -221,14 +224,14 @@ public class ProcessPaymentsApplication implements CommandLineRunner {
```java
@Override
public void run(final String... args) {
var processDefinitionKey = "process-payments";
var bpmnProcessId = "process-payments";
christinaausley marked this conversation as resolved.
Show resolved Hide resolved
var event = zeebeClient.newCreateInstanceCommand()
.bpmnProcessId(processDefinitionKey)
.bpmnProcessId(bpmnProcessId)
.latestVersion()
.variables(Map.of("total", 100))
.send()
.join();
LOG.info(String.format("started a process: %d", event.getProcessInstanceKey()));
LOG.info("started a process instance: {}", event.getProcessInstanceKey());
}
```

Expand All @@ -243,6 +246,12 @@ Re-run the application in your terminal with `mvn spring-boot:run` to see the pr
To deploy your process, take the following steps:

1. Decorate the `ProcessPaymentsApplication` class with `@Deployment(resources = "classpath:process-payments.bpmn")` in `ProcessPaymentsApplication.java`:

```java
@SpringBootApplication
@Deployment(resources = "classpath:process-payments.bpmn")
```

2. In Desktop Modeler, change the tax amount calculated to `total * 1.2` under **FEEL expression** and save your changes.

Re-run the application in your terminal with `mvn spring-boot:run` to see the process run. In Operate, note the new version `2` when filtering process instances, and the tax amount has increased for the most recent process instance.
46 changes: 23 additions & 23 deletions versioned_docs/version-8.5/guides/getting-started-java-spring.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
---
id: getting-started-java-spring
title: Getting started as a Java developer using Spring
sidebar_label: Getting started as a Java developer using Spring
title: Get started as a Java developer using Spring
sidebar_label: Get started with Spring
description: "Use Spring Boot and the Spring Zeebe SDK to interact with your local Self-Managed Camunda 8 installation."
keywords: [java, spring, spring zeebe, getting started, user guide, tutorial]
---

import SmPrereqs from './react-components/sm-prerequisites.md'
import Install from './react-components/install-plain-java.md'
christinaausley marked this conversation as resolved.
Show resolved Hide resolved

<span class="badge badge--beginner">Beginner</span>
<span class="badge badge--medium">1 hour</span>
<span class="badge badge--medium">1 hour</span><br /><br />

:::note
This tutorial is not intended for production purposes.
:::

In this guide, we'll step through using Spring Boot and the [Spring Zeebe SDK](/apis-tools/spring-zeebe-sdk/getting-started.md) with Desktop Modeler to interact with your local Self-Managed Camunda 8 installation.
In this guide, we'll step through using Spring Boot and the [Spring Zeebe SDK](/apis-tools/spring-zeebe-sdk/getting-started.md) with Desktop Modeler to interact with your local Self-Managed Camunda 8 installation. While this guide focuses on Self-Managed, you can do something similar with [SaaS](https://signup.camunda.com/accounts?utm_source=docs.camunda.io&utm_medium=referral).

By the end of this tutorial, you'll be able to use Spring and Java code with Zeebe to:

Expand All @@ -22,26 +29,14 @@ For example, in this guide we will outline a BPMN model to receive a payment req
![example BPMN model to receive a payment request, prepare a transaction, charge a credit card, and execute a payment](./img/prepare-transaction-example.png)

:::note
This tutorial is not intended for production purposes.
While stepping through this guide, you can visit our [sample repository](https://github.com/camunda/camunda-8-get-started-spring/blob/main/src/main/java/io/camunda/demo/process_payments/ChargeCreditCardWorker.java) with the completed code to check your work.
:::

## Prerequisites

Before getting started, ensure you:

- Can access your preferred code editor or IDE.
- Have Java [installed locally](https://www.java.com/en/download/). Currently, the Spring Initializr supports Java versions 17, 21, and 22.
- Have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed locally.
- Install [Desktop Modeler](https://camunda.com/download/modeler/).
<SmPrereqs/>
christinaausley marked this conversation as resolved.
Show resolved Hide resolved

## Step 1: Install Camunda 8 Self-Managed

If you haven't already, follow [this guide](/self-managed/setup/deploy/local/docker-compose.md) to install Camunda 8 Self-Managed locally via Docker Compose:

1. Use the `docker-compose.yaml` file in [this repository](https://github.com/camunda/camunda-platform).
2. Clone this repo and run `docker compose up -d` in your terminal to start your environment.

To confirm Camunda 8 Self-Managed is installed, click into Docker Desktop. Here, you will see the `camunda-platform` container. Alternatively, navigate to the different components and log in with the username `demo` and password `demo`. For example, Operate can be accessed at [http://localhost:8081](http://localhost:8081) (as noted under **Port(s)** in the Docker container). Find additional guidance in the repository [README](https://github.com/camunda/camunda-platform?tab=readme-ov-file#using-docker-compose).
<Install/>
christinaausley marked this conversation as resolved.
Show resolved Hide resolved

## Step 2: Create a new Spring Boot project

Expand Down Expand Up @@ -211,7 +206,6 @@ import io.camunda.zeebe.spring.client.annotation.Deployment;

```java
@SpringBootApplication
@Deployment(resources = "classpath:process-payments.bpmn")
public class ProcessPaymentsApplication implements CommandLineRunner {

private static final Logger LOG = LoggerFactory.getLogger(ProcessPaymentsApplication.class);
Expand All @@ -230,14 +224,14 @@ public class ProcessPaymentsApplication implements CommandLineRunner {
```java
@Override
public void run(final String... args) {
var processDefinitionKey = "process-payments";
var bpmnProcessId = "process-payments";
var event = zeebeClient.newCreateInstanceCommand()
.bpmnProcessId(processDefinitionKey)
.bpmnProcessId(bpmnProcessId)
.latestVersion()
.variables(Map.of("total", 100))
.send()
.join();
LOG.info(String.format("started a process: %d", event.getProcessInstanceKey()));
LOG.info("started a process instance: {}", event.getProcessInstanceKey());
}
```

Expand All @@ -252,6 +246,12 @@ Re-run the application in your terminal with `mvn spring-boot:run` to see the pr
To deploy your process, take the following steps:

1. Decorate the `ProcessPaymentsApplication` class with `@Deployment(resources = "classpath:process-payments.bpmn")` in `ProcessPaymentsApplication.java`:

```java
@SpringBootApplication
@Deployment(resources = "classpath:process-payments.bpmn")
```

2. In Desktop Modeler, change the tax amount calculated to `total * 1.2` under **FEEL expression** and save your changes.

Re-run the application in your terminal with `mvn spring-boot:run` to see the process run. In Operate, note the new version `2` when filtering process instances, and the tax amount has increased for the most recent process instance.
Loading