Skip to content

Commit f143cb9

Browse files
committed
clean up logs for multiple executions, for standalone mode
Signed-off-by: salaboy <[email protected]>
1 parent 780c7a2 commit f143cb9

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.springboot.examples.wfp;
15+
16+
import io.dapr.springboot.examples.wfp.continueasnew.CleanUpLog;
17+
import org.springframework.context.annotation.Bean;
18+
import org.springframework.context.annotation.Configuration;
19+
20+
@Configuration
21+
public class WorkflowPatternsConfiguration {
22+
@Bean
23+
public CleanUpLog cleanUpLog(){
24+
return new CleanUpLog();
25+
}
26+
}

spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsRestController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929
import org.springframework.beans.factory.annotation.Autowired;
30-
import org.springframework.context.annotation.Bean;
3130
import org.springframework.web.bind.annotation.PostMapping;
3231
import org.springframework.web.bind.annotation.RequestBody;
3332
import org.springframework.web.bind.annotation.RequestParam;
@@ -48,12 +47,11 @@ public class WorkflowPatternsRestController {
4847
@Autowired
4948
private DaprWorkflowClient daprWorkflowClient;
5049

50+
@Autowired
51+
private CleanUpLog cleanUpLog;
52+
5153
private Map<String, String> ordersToApprove = new HashMap<>();
5254

53-
@Bean
54-
public CleanUpLog cleanUpLog(){
55-
return new CleanUpLog();
56-
}
5755

5856
/**
5957
* Run Chain Demo Workflow
@@ -129,6 +127,8 @@ public Decision externalEventContinue(@RequestParam("orderId") String orderId, @
129127
@PostMapping("wfp/continueasnew")
130128
public CleanUpLog continueAsNew()
131129
throws TimeoutException {
130+
131+
cleanUpLog.clearLog();
132132
String instanceId = daprWorkflowClient.scheduleNewWorkflow(ContinueAsNewWorkflow.class);
133133
logger.info("Workflow instance " + instanceId + " started");
134134

spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/continueasnew/CleanUpLog.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ public void increment() {
2626
public Integer getCleanUpTimes() {
2727
return cleanUpTimes;
2828
}
29+
30+
public void clearLog(){
31+
this.cleanUpTimes = 0;
32+
}
2933
}
3034

0 commit comments

Comments
 (0)