Open
Conversation
nemoguigrat
reviewed
May 10, 2025
nemoguigrat
left a comment
There was a problem hiding this comment.
Вообще выглядит интересно, но ничего не работает. Из за отсутствия транзакции дальше события не прокидываются и не обрабатываются
| public void handlePaymentSuccessEvent(PaymentProcessedEvent event) { | ||
| log.info("Handle PaymentProcessedEvent (AFTER_COMMIT)..."); | ||
| log.info("Publish OrderCreatedEvent."); | ||
| eventPublisher.publishEvent(new OrderCreatedEvent()); |
There was a problem hiding this comment.
не обязательно публиковать. Можно сделать return этого события. Спринг сам его опубликует
| public class PaymentService { | ||
| private final ApplicationEventPublisher eventPublisher; | ||
|
|
||
| @Transactional(value = REQUIRES_NEW, rollbackOn = Exception.class) |
There was a problem hiding this comment.
Я пробовал запускать проект и транзакция здесь не открывается даже с этими параметрами. Попробуй пересмотреть логику
| @Log4j2 | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class PaymentEventListener { |
There was a problem hiding this comment.
Точно такой же перехватчик находится в пакете org.javaspringcourse.order.eventListener. Зачем это нужно?
| @@ -0,0 +1,27 @@ | |||
| package org.javaspringcourse.payment.eventListener; | |||
There was a problem hiding this comment.
пакеты в java лучше называть либо одним словом, либо без разделителей. eventlistener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Студент: Аптуликсанов Руслан Германович
Преподаватель: Никита Иванов
handleOrderCreatedEvent- обычный,handleOrderCreatingEvent- async, классыPaymentProcessedEventListenerиPaymentEventListener- содержат TransactionalEventListener)PaymentProcessedEventListenerиPaymentEventListenerс помощью фаз AFTER_COMMIT и AFTER_ROLLBACK)В этом задании я попытался реализовать связь двух условных микросервисов OrderService и PaymentService через события и обработчики (в каждом сервисе стоят обработчики на события другого сервиса) (поэтому листенеров чуть больше, чем в условии).