네임드 락을 활용한 동시성 제어동시성 문제 - 중복 저장@Componentclass SubscribeWorkbookUseCase( private val subscriptionDao: SubscriptionDao, private val applicationEventPublisher: ApplicationEventPublisher,) { @Transactional fun execute(useCaseIn: SubscribeWorkbookUseCaseIn) {belljundev.tistory.com 최근 AOP에 대해 다시 공부하며 AOP와 네임드 락을 활용하여 중복 구독 방지를 위해 구현하였던 LockAspect가 문제가 있지 않을까? 하는 생각을 하였습니다.AOP를 다시 공부하기 이전 제가 생각하였던 기존 ..
private Object resolveInstance(Object candidate, DependencyDescriptor descriptor, Class type, String name) { Object result = candidate; if (result instanceof NullBean) { // Raise exception if null encountered for required injection point if (isRequired(descriptor)) { raiseNoMatchingBeanFound(type, descriptor.getResolvableType(), descriptor); } ..
트랜잭션을 위한 어드바이저트랜잭션을 위한 어드바이저는 ProxyTransactionManagementConfiguration에서 등록되는 BeanFactoryTransactionAttributeSourceAdvisor를 통해 생성됩니다. AspectJ로 선언한 어드바이저우선 AspectJ는 @EnableAspectJAutoProxy를 통해 활성화합니다.이후 @EnableAspectJAutoProxy를 통해 등록된 AspectJAutoProxyRegistrar에서 AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry)를 통해 org.springframework.aop.config.internalAutoProxyCreator..
Spring이 시작되면 AbstractApplicationContext의 refresh 메서드를 통해 컨텍스트 관련 설정이 시작됩니다. ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();// Invoke factory processors registered as beans in the context. invokeBeanFactoryPostProcessors(beanFactory); // Register bean processors that intercept bean creation. registerBeanPostProcessors(beanFactory); // Instantiate all remaining (non-laz..
@Transactional 메서드가 실행되는 과정Spring에서 @Transactional이 선언된 메서드를 실행할 때, 내부적으로 TransactionAspectSupport의 invokeWithinTransaction 메서드가 호출됩니다. // spring-tx 6.1.6 기준// This is an around advice: Invoke the next interceptor in the chain. // This will normally result in a target object being invoked. retVal = invocation.proceedWithInvocation();해당 메서드의 392번 라인에서 invocation.proceedWithInvocation()을 호출하며, 트..
Spring TestContext 프레임워크는 단일 JVM 내에서 테스트를 병렬로 실행하기 위한 기본적인 지원을 제공한다.테스트 스위트에 동시성을 도입하면 예기치 않은 부작용, 이상한 런타임 동작, 간헐적으로 또는 무작위로 실패하는 테스트가 발생할 수 있다. 따라서 Spring 팀은 테스트를 병렬로 실행하지 않는 경우에 대한 다음과 같은 일반적인 지침을 제공한다. 병렬로 테스트하는 것을 권장하지 않는 경우테스트가 다음과 같은 경우 테스트를 병렬로 실행하지 말자.Spring 프레임워크의 @DirtiesContext를 사용하는 경우Spring Framework의 @MockitoBean 또는 @MockitoSpyBean을 사용하는 경우Spring Boot의 @MockBean 또는 @SpyBean을 사용하는 경..