Skip to content
Snippets Groups Projects
Commit b81c4113 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6280 change thread configuration

parent 037ec241
No related branches found
No related tags found
No related merge requests found
...@@ -28,10 +28,14 @@ import java.util.TimeZone; ...@@ -28,10 +28,14 @@ import java.util.TimeZone;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Primary;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.concurrent.DelegatingSecurityContextRunnable; import org.springframework.security.concurrent.DelegatingSecurityContextRunnable;
...@@ -49,14 +53,31 @@ public class AlfaServerApplication { ...@@ -49,14 +53,31 @@ public class AlfaServerApplication {
} }
@Bean @Bean
public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() { ThreadPoolTaskExecutorCustomizer addSecurityContextCustomizer() {
return customizer -> customizer.setTaskDecorator(DelegatingSecurityContextRunnable::new);
}
@Bean
ThreadPoolTaskExecutorCustomizer setThreadName() {
return customizer -> customizer.setThreadNamePrefix("ozgtask-");
}
@Bean("taskExecutor")
@Primary
TaskExecutor taskExecutor(ThreadPoolTaskExecutorBuilder builder) {
return builder.build();
}
// @Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>(); FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter()); bean.setFilter(new ForwardedHeaderFilter());
return bean; return bean;
} }
@Bean // @Bean
public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("async-"); executor.setThreadNamePrefix("async-");
...@@ -65,12 +86,12 @@ public class AlfaServerApplication { ...@@ -65,12 +86,12 @@ public class AlfaServerApplication {
} }
@Bean @Bean
public CallScope callScope() { CallScope callScope() {
return new CallScope(); return new CallScope();
} }
@Bean @Bean
public BeanFactoryPostProcessor beanFactoryPostProcessor(CallScope callScope) { BeanFactoryPostProcessor beanFactoryPostProcessor(CallScope callScope) {
return new CallBeanFactoryPostProcessor(callScope); return new CallBeanFactoryPostProcessor(callScope);
} }
} }
\ No newline at end of file
...@@ -84,6 +84,7 @@ class GrpcFormDataMapperTest { ...@@ -84,6 +84,7 @@ class GrpcFormDataMapperTest {
assertThat(formData.getField(0).getName()).isEqualTo("key"); assertThat(formData.getField(0).getName()).isEqualTo("key");
assertThat(formData.getField(0).getValue()).isEqualTo("value"); assertThat(formData.getField(0).getValue()).isEqualTo("value");
} }
} }
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment