-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…lt-aop Amazon SNS Topic 메시지 전송 관심사를 Aspect로 분리
- Loading branch information
Showing
3 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/today/seasoning/seasoning/common/aspect/NotifyResult.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package today.seasoning.seasoning.common.aspect; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
// Amazon SNS Topic으로 실행 결과를 전송할 메서드에 붙이는 어노테이션 | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NotifyResult { | ||
|
||
// 작업명 | ||
String name(); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/today/seasoning/seasoning/common/aspect/NotifyResultAspect.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package today.seasoning.seasoning.common.aspect; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.aspectj.lang.annotation.AfterReturning; | ||
import org.aspectj.lang.annotation.AfterThrowing; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.stereotype.Component; | ||
import today.seasoning.seasoning.common.aws.SnsService; | ||
|
||
@Aspect | ||
@Component | ||
@RequiredArgsConstructor | ||
public class NotifyResultAspect { | ||
|
||
private final SnsService snsService; | ||
|
||
@AfterReturning(pointcut = "@annotation(notifyResult)") | ||
public void reportSuccessResult(NotifyResult notifyResult) { | ||
snsService.publish("[시즈닝] " + notifyResult.name() + " 완료"); | ||
} | ||
|
||
@AfterThrowing(pointcut = "@annotation(notifyResult)") | ||
public void reportFailureResult(NotifyResult notifyResult) { | ||
snsService.publish("[시즈닝] " + notifyResult.name() + " 실패"); | ||
} | ||
} |
This file contains 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