Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions apps/user-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies {
implementation "io.micrometer:micrometer-tracing"
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "io.micrometer:context-propagation"

// Lombok
compileOnly 'org.projectlombok:lombok:1.18.30'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package site.icebang.domain.workflow.controller;

import java.util.concurrent.CompletableFuture;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -31,7 +29,7 @@ public ApiResponse<PageResult<WorkflowCardDto>> getWorkflowList(
@PostMapping("/{workflowId}/run")
public ResponseEntity<Void> runWorkflow(@PathVariable Long workflowId) {
// HTTP 요청/응답 스레드를 블로킹하지 않도록 비동기 실행
CompletableFuture.runAsync(() -> workflowExecutionService.executeWorkflow(workflowId));
workflowExecutionService.executeWorkflow(workflowId);
return ResponseEntity.accepted().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -43,6 +44,7 @@ public class WorkflowExecutionService {
private final List<TaskBodyBuilder> bodyBuilders;

@Transactional
@Async("traceExecutor")
public void executeWorkflow(Long workflowId) {
log.info("========== 워크플로우 실행 시작: WorkflowId={} ==========", workflowId);
WorkflowRun workflowRun = WorkflowRun.start(workflowId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package site.icebang.global.config.asnyc;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.support.ContextPropagatingTaskDecorator;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@EnableAsync
public class AsyncConfig {

@Bean("traceExecutor")
public ThreadPoolTaskExecutor traceExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(50);
executor.setQueueCapacity(100);
executor.setTaskDecorator(new ContextPropagatingTaskDecorator()); // 필수
executor.setThreadNamePrefix("trace-");
executor.initialize();
return executor;
}
}
Loading