-
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.
Merge pull request #186 from TEAM-SAMSION/main
release : 1.1.1 배포
- Loading branch information
Showing
165 changed files
with
3,279 additions
and
868 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM amazoncorretto:17 | ||
FROM amazoncorretto:17-alpine-jdk | ||
ARG JAR_FILE=/Api-Module/build/libs/Api-Module-0.0.1.jar | ||
COPY ${JAR_FILE} pawith.jar | ||
ENTRYPOINT ["java","-Dcom.mysql.cj.disableAbandonedConnectionCleanup=true","-jar","/pawith.jar"] |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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
53 changes: 53 additions & 0 deletions
53
Alarm-Module/src/main/java/com/pawith/alarmmodule/fcm/FcmSendMessageHandler.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,53 @@ | ||
package com.pawith.alarmmodule.fcm; | ||
|
||
import com.google.firebase.messaging.FirebaseMessaging; | ||
import com.google.firebase.messaging.FirebaseMessagingException; | ||
import com.google.firebase.messaging.Message; | ||
import com.google.firebase.messaging.Notification; | ||
import com.pawith.alarmmodule.exception.AlarmError; | ||
import com.pawith.alarmmodule.exception.FcmException; | ||
import com.pawith.alarmmodule.handler.NotificationHandler; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.retry.annotation.Backoff; | ||
import org.springframework.retry.annotation.Retryable; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Collection; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FcmSendMessageHandler implements NotificationHandler<FcmSendMessageHandler.NotificationInfo> { | ||
private final FirebaseMessaging firebaseMessaging; | ||
private final ExecutorService executorService = Executors.newFixedThreadPool(10); | ||
|
||
@Retryable( | ||
retryFor = FcmException.class, | ||
maxAttempts = 3, | ||
backoff = @Backoff(delay = 1000) | ||
) | ||
public void send(final NotificationInfo notificationInfo) { | ||
final Message message = Message.builder() | ||
.setToken(notificationInfo.deviceToken) | ||
.setNotification(notificationInfo.notification) | ||
.build(); | ||
try { | ||
firebaseMessaging.send(message); | ||
} catch (FirebaseMessagingException e) { | ||
throw new FcmException(AlarmError.FCM_SEND_ERROR); | ||
} | ||
} | ||
|
||
public void sendAsync(final NotificationInfo notificationInfo){ | ||
executorService.submit(() -> { | ||
send(notificationInfo); | ||
}); | ||
} | ||
|
||
public void sendMultiAsync(Collection<NotificationInfo> notificationInfoList){ | ||
notificationInfoList.forEach(this::sendAsync); | ||
} | ||
|
||
public record NotificationInfo(String deviceToken, Notification notification){ } | ||
} |
11 changes: 11 additions & 0 deletions
11
Alarm-Module/src/main/java/com/pawith/alarmmodule/handler/NotificationHandler.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,11 @@ | ||
package com.pawith.alarmmodule.handler; | ||
|
||
import java.util.Collection; | ||
|
||
public interface NotificationHandler<T> { | ||
void send(T t); | ||
|
||
void sendMultiAsync(Collection<T> t); | ||
|
||
void sendAsync(T t); | ||
} |
11 changes: 11 additions & 0 deletions
11
Alarm-Module/src/main/java/com/pawith/alarmmodule/repository/AlarmBatchRepository.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,11 @@ | ||
package com.pawith.alarmmodule.repository; | ||
|
||
import com.pawith.alarmmodule.entity.Alarm; | ||
import org.springframework.data.repository.NoRepositoryBean; | ||
|
||
import java.util.Collection; | ||
|
||
@NoRepositoryBean | ||
public interface AlarmBatchRepository{ | ||
void saveAllBatch(Collection<Alarm> entities); | ||
} |
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
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
32 changes: 32 additions & 0 deletions
32
...Module/src/main/java/com/pawith/alarmmodule/repository/impl/AlarmBatchRepositoryImpl.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,32 @@ | ||
package com.pawith.alarmmodule.repository; | ||
|
||
import com.pawith.alarmmodule.entity.Alarm; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Collection; | ||
|
||
@Repository | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class AlarmBatchRepositoryImpl implements AlarmBatchRepository{ | ||
private final JdbcTemplate jdbcTemplate; | ||
|
||
@Override | ||
public void saveAllBatch(Collection<Alarm> entities) { | ||
final String insertSql = """ | ||
INSERT INTO alarm (domain_id, message, alarm_category,is_read,alarm_user_id,created_at, updated_at) | ||
VALUES (?, ?, ?, ?, ?,now(),now()) | ||
"""; | ||
|
||
jdbcTemplate.batchUpdate(insertSql, entities, 1000, (ps, alarm) -> { | ||
ps.setLong(1, alarm.getAlarmBody().getDomainId()); | ||
ps.setString(2, alarm.getAlarmBody().getMessage()); | ||
ps.setString(3, alarm.getAlarmCategory().toString()); | ||
ps.setBoolean(4, alarm.getIsRead()); | ||
ps.setLong(5, alarm.getAlarmUser().getId()); | ||
}); | ||
} | ||
} |
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
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
5 changes: 5 additions & 0 deletions
5
Alarm-Module/src/main/java/com/pawith/alarmmodule/service/MultiAlarmSendService.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,5 @@ | ||
package com.pawith.alarmmodule.service; | ||
|
||
public interface MultiAlarmSendService<T> { | ||
void sendAlarm(T t); | ||
} |
Oops, something went wrong.