diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c094f92fa..06c911702 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,48 @@ This section describes the guidelines for contributing code / docs to Dapr. ### Things to consider when adding new API to SDK 1. All the new API's go under [dapr-sdk maven package](https://github.com/dapr/java-sdk/tree/master/sdk) -2. Make sure there is an example talking about how to use the API along with a README. [Example](https://github.com/dapr/java-sdk/pull/1235/files#diff-69ed756c4c01fd5fa884aac030dccb8f3f4d4fefa0dc330862d55a6f87b34a14) +2. Make sure there is an example talking about how to use the API along with a README with mechanical markdown. [Example](https://github.com/dapr/java-sdk/pull/1235/files#diff-69ed756c4c01fd5fa884aac030dccb8f3f4d4fefa0dc330862d55a6f87b34a14) + +#### Mechanical Markdown + +Mechanical markdown is used to validate example outputs in our CI pipeline. It ensures that the expected output in README files matches the actual output when running the examples. This helps maintain example output, catches any unintended changes in example behavior, and regressions. + +To test mechanical markdown locally: + +1. Install the package: +```bash +pip3 install mechanical-markdown +``` + +2. Run the test from the respective examples README directory, for example: +```bash +cd examples +mm.py ./src/main/java/io/dapr/examples/workflows/README.md +``` + +The test will: +- Parse the STEP markers in the README +- Execute the commands specified in the markers +- Compare the actual output with the expected output +- Report any mismatches + +When writing STEP markers: +- Use `output_match_mode: substring` for flexible matching +- Quote strings containing special YAML characters (like `:`, `*`, `'`) +- Set appropriate timeouts for long-running examples + +Example STEP marker: +```yaml + +``` ### Pull Requests diff --git a/examples/src/main/java/io/dapr/examples/workflows/README.md b/examples/src/main/java/io/dapr/examples/workflows/README.md index 047f1d744..4d9c057f2 100644 --- a/examples/src/main/java/io/dapr/examples/workflows/README.md +++ b/examples/src/main/java/io/dapr/examples/workflows/README.md @@ -51,7 +51,8 @@ Those examples contain the following workflow patterns: 2. [Fan-out/Fan-in Pattern](#fan-outfan-in-pattern) 3. [Continue As New Pattern](#continue-as-new-pattern) 4. [External Event Pattern](#external-event-pattern) -5. [child-workflow Pattern](#child-workflow-pattern) +5. [Child-workflow Pattern](#child-workflow-pattern) +6. [Compensation Pattern](#compensation-pattern) ### Chaining Pattern In the chaining pattern, a sequence of activities executes in a specific order. @@ -353,7 +354,7 @@ dapr run --app-id demoworkflowworker --resources-path ./components/workflows -- ``` ```sh java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.continueasnew.DemoContinueAsNewClient -```` +``` You will see the logs from worker showing the `CleanUpActivity` is invoked every 10 seconds after previous one is finished: ```text @@ -444,7 +445,7 @@ Started a new external-event model workflow with instance ID: 23410d96-1afe-4698 workflow instance with ID: 23410d96-1afe-4698-9fcd-c01c1e0db255 completed. ``` -### child-workflow Pattern +### Child-workflow Pattern The child-workflow pattern allows you to call a workflow from another workflow. The `DemoWorkflow` class defines the workflow. It calls a child-workflow `DemoChildWorkflow` to do the work. See the code snippet below: @@ -540,3 +541,115 @@ The log from client: Started a new child-workflow model workflow with instance ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb workflow instance with ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb completed with result: !wolfkroW rpaD olleH ``` + +### Compensation Pattern +The compensation pattern is used to "undo" or "roll back" previously completed steps if a later step fails. This pattern is particularly useful in scenarios where you need to ensure that all resources are properly cleaned up even if the process fails. + +The example simulates a trip booking workflow that books a flight, hotel, and car. If any step fails, the workflow will automatically compensate (cancel) the previously completed bookings in reverse order. + +The `BookTripWorkflow` class defines the workflow. It orchestrates the booking process and handles compensation if any step fails. See the code snippet below: +```java +public class BookTripWorkflow extends Workflow { + @Override + public WorkflowStub create() { + return ctx -> { + List compensations = new ArrayList<>(); + + try { + // Book flight + String flightResult = ctx.callActivity(BookFlightActivity.class.getName(), String.class).await(); + ctx.getLogger().info("Flight booking completed: " + flightResult); + compensations.add(CancelFlightActivity.class.getName()); + + // Book hotel + String hotelResult = ctx.callActivity(BookHotelActivity.class.getName(), String.class).await(); + ctx.getLogger().info("Hotel booking completed: " + hotelResult); + compensations.add(CancelHotelActivity.class.getName()); + + // Book car + String carResult = ctx.callActivity(BookCarActivity.class.getName(), String.class).await(); + ctx.getLogger().info("Car booking completed: " + carResult); + compensations.add(CancelCarActivity.class.getName()); + + } catch (Exception e) { + ctx.getLogger().info("******** executing compensation logic ********"); + // Execute compensations in reverse order + Collections.reverse(compensations); + for (String compensation : compensations) { + try { + ctx.callActivity(compensation, String.class).await(); + } catch (Exception ex) { + ctx.getLogger().error("Error during compensation: " + ex.getMessage()); + } + } + ctx.complete("Workflow failed, compensation applied"); + return; + } + ctx.complete("All bookings completed successfully"); + }; + } +} +``` + +Each activity class (`BookFlightActivity`, `BookHotelActivity`, `BookCarActivity`) implements the booking logic, while their corresponding compensation activities (`CancelFlightActivity`, `CancelHotelActivity`, `CancelCarActivity`) implement the cancellation logic. + + + +Execute the following script in order to run the BookTripWorker: +```sh +dapr run --app-id book-trip-worker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripWorker +``` + +Once running, execute the following script to run the BookTripClient: +```sh +java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient +``` + + +The output demonstrates: +1. The workflow starts and successfully books a flight +2. Then successfully books a hotel +3. When attempting to book a car, it fails (intentionally) +4. The compensation logic triggers, canceling the hotel and flight in reverse order +5. The workflow completes with a status indicating the compensation was applied + +Key Points: +1. Each successful booking step adds its compensation action to an ArrayList +2. If an error occurs, the list of compensations is reversed and executed in reverse order +3. The workflow ensures that all resources are properly cleaned up even if the process fails +4. Each activity simulates work with a short delay for demonstration purposes \ No newline at end of file diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookCarActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookCarActivity.java new file mode 100644 index 000000000..9ad0285d9 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookCarActivity.java @@ -0,0 +1,42 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class BookCarActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(BookCarActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + + // Simulate work + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + logger.info("Forcing Failure to trigger compensation for activity: " + ctx.getName()); + + // force the compensation + throw new RuntimeException("Failed to book car"); + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookFlightActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookFlightActivity.java new file mode 100644 index 000000000..075c4d275 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookFlightActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class BookFlightActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(BookFlightActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + + // Simulate work + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + String result = "Flight booked successfully"; + logger.info("Activity completed with result: " + result); + return result; + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookHotelActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookHotelActivity.java new file mode 100644 index 000000000..a2eca04c4 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookHotelActivity.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BookHotelActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(BookHotelActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + logger.info("Simulating hotel booking process..."); + + // Simulate some work + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + String result = "Hotel booked successfully"; + logger.info("Activity completed with result: " + result); + return result; + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java new file mode 100644 index 000000000..212c1f0a1 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java @@ -0,0 +1,35 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.client.DaprWorkflowClient; +import io.dapr.workflows.client.WorkflowInstanceStatus; + +import java.time.Duration; +import java.util.concurrent.TimeoutException; + +public class BookTripClient { + public static void main(String[] args) { + try (DaprWorkflowClient client = new DaprWorkflowClient()) { + String instanceId = client.scheduleNewWorkflow(BookTripWorkflow.class); + System.out.printf("Started a new trip booking workflow with instance ID: %s%n", instanceId); + + WorkflowInstanceStatus status = client.waitForInstanceCompletion(instanceId, Duration.ofMinutes(30), true); + System.out.printf("Workflow instance with ID: %s completed with status: %s%n", instanceId, status); + System.out.printf("Workflow output: %s%n", status.getSerializedOutput()); + } catch (TimeoutException | InterruptedException e) { + throw new RuntimeException(e); + } + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java new file mode 100644 index 000000000..d32ade26a --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java @@ -0,0 +1,38 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.runtime.WorkflowRuntime; +import io.dapr.workflows.runtime.WorkflowRuntimeBuilder; + +public class BookTripWorker { + + public static void main(String[] args) throws Exception { + // Register the Workflow with the builder + WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder() + .registerWorkflow(BookTripWorkflow.class) + .registerActivity(BookFlightActivity.class) + .registerActivity(CancelFlightActivity.class) + .registerActivity(BookHotelActivity.class) + .registerActivity(CancelHotelActivity.class) + .registerActivity(BookCarActivity.class) + .registerActivity(CancelCarActivity.class); + + // Build and start the workflow runtime + try (WorkflowRuntime runtime = builder.build()) { + System.out.println("Start workflow runtime"); + runtime.start(); + } + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorkflow.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorkflow.java new file mode 100644 index 000000000..f375363ed --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorkflow.java @@ -0,0 +1,107 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.durabletask.TaskFailedException; +import io.dapr.workflows.Workflow; +import io.dapr.workflows.WorkflowStub; +import io.dapr.workflows.WorkflowTaskOptions; +import io.dapr.workflows.WorkflowTaskRetryPolicy; + +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; +import java.time.Duration; + +public class BookTripWorkflow implements Workflow { + @Override + public WorkflowStub create() { + return ctx -> { + ctx.getLogger().info("Starting Workflow: " + ctx.getName()); + List compensations = new ArrayList<>(); + + // Define retry policy for compensation activities + WorkflowTaskRetryPolicy compensationRetryPolicy = WorkflowTaskRetryPolicy.newBuilder() + .setFirstRetryInterval(Duration.ofSeconds(1)) + .setMaxNumberOfAttempts(3) + .build(); + + WorkflowTaskOptions compensationOptions = new WorkflowTaskOptions(compensationRetryPolicy); + + try { + // Book flight + String flightResult = ctx.callActivity(BookFlightActivity.class.getName(), null, String.class).await(); + ctx.getLogger().info("Flight booking completed: {}", flightResult); + compensations.add("CancelFlight"); + + // Book hotel + String hotelResult = ctx.callActivity(BookHotelActivity.class.getName(), null, String.class).await(); + ctx.getLogger().info("Hotel booking completed: {}", hotelResult); + compensations.add("CancelHotel"); + + // Book car + String carResult = ctx.callActivity(BookCarActivity.class.getName(), null, String.class).await(); + ctx.getLogger().info("Car booking completed: {}", carResult); + compensations.add("CancelCar"); + + String result = String.format("%s, %s, %s", flightResult, hotelResult, carResult); + ctx.getLogger().info("Trip booked successfully: {}", result); + ctx.complete(result); + + } catch (TaskFailedException e) { + ctx.getLogger().info("******** executing compensation logic ********"); + ctx.getLogger().error("Activity failed: {}", e.getMessage()); + + // Execute compensations in reverse order + Collections.reverse(compensations); + for (String compensation : compensations) { + try { + switch (compensation) { + case "CancelCar": + String carCancelResult = ctx.callActivity( + CancelCarActivity.class.getName(), + null, + compensationOptions, + String.class).await(); + ctx.getLogger().info("Car cancellation completed: {}", carCancelResult); + break; + + case "CancelHotel": + String hotelCancelResult = ctx.callActivity( + CancelHotelActivity.class.getName(), + null, + compensationOptions, + String.class).await(); + ctx.getLogger().info("Hotel cancellation completed: {}", hotelCancelResult); + break; + + case "CancelFlight": + String flightCancelResult = ctx.callActivity( + CancelFlightActivity.class.getName(), + null, + compensationOptions, + String.class).await(); + ctx.getLogger().info("Flight cancellation completed: {}", flightCancelResult); + break; + } + } catch (TaskFailedException ex) { + // Only catch TaskFailedException for actual activity failures + ctx.getLogger().error("Activity failed during compensation: {}", ex.getMessage()); + } + } + ctx.complete("Workflow failed, compensation applied"); + } + }; + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelCarActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelCarActivity.java new file mode 100644 index 000000000..bca6af0da --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelCarActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class CancelCarActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(CancelCarActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + + // Simulate work + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + String result = "Car canceled successfully"; + logger.info("Activity completed with result: " + result); + return result; + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelFlightActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelFlightActivity.java new file mode 100644 index 000000000..0c2034dee --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelFlightActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class CancelFlightActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(CancelFlightActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + + // Simulate work + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + String result = "Flight canceled successfully"; + logger.info("Activity completed with result: " + result); + return result; + } +} diff --git a/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelHotelActivity.java b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelHotelActivity.java new file mode 100644 index 000000000..03f5f9b64 --- /dev/null +++ b/examples/src/main/java/io/dapr/examples/workflows/compensation/CancelHotelActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright 2025 The Dapr Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and +limitations under the License. +*/ + +package io.dapr.examples.workflows.compensation; + +import io.dapr.workflows.WorkflowActivity; +import io.dapr.workflows.WorkflowActivityContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +public class CancelHotelActivity implements WorkflowActivity { + private static final Logger logger = LoggerFactory.getLogger(CancelHotelActivity.class); + + @Override + public String run(WorkflowActivityContext ctx) { + logger.info("Starting Activity: " + ctx.getName()); + + // Simulate work + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + String result = "Hotel canceled successfully"; + logger.info("Activity completed with result: " + result); + return result; + } +}