-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaMailSenderStrategy.java
More file actions
34 lines (29 loc) · 1.05 KB
/
JavaMailSenderStrategy.java
File metadata and controls
34 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.example.cs25batch.sender;
import com.example.cs25batch.batch.dto.MailDto;
import com.example.cs25batch.batch.service.JavaMailService;
import io.github.bucket4j.Bandwidth;
import io.github.bucket4j.Bucket;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.time.Duration;
@Component("javaBatchMailSender")
@RequiredArgsConstructor
public class JavaMailSenderStrategy implements MailSenderStrategy{
private final JavaMailService javaMailService;
private final Bucket bucket = Bucket.builder()
.addLimit(
Bandwidth.builder()
.capacity(4)
.refillGreedy(2, Duration.ofMillis(500))
.build()
)
.build();
@Override
public void sendQuizMail(MailDto mailDto) {
javaMailService.sendQuizEmail(mailDto.getSubscription(), mailDto.getQuiz()); // 커스텀 메서드로 정의
}
@Override
public Bucket getBucket() {
return bucket;
}
}