-
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 #33 from kusitms-28th-Meetup-E/feat/rabbit
feat : rabbitMQ 구현
- Loading branch information
Showing
8 changed files
with
112 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package gwangjang.server.global.rabbitMQ; | ||
|
||
public class Email { | ||
|
||
private String to; | ||
private String body; | ||
|
||
public Email() { | ||
} | ||
|
||
public Email(String to, String body) { | ||
this.to = to; | ||
this.body = body; | ||
} | ||
|
||
public String getTo() { | ||
return to; | ||
} | ||
|
||
public void setTo(String to) { | ||
this.to = to; | ||
} | ||
|
||
public String getBody() { | ||
return body; | ||
} | ||
|
||
public void setBody(String body) { | ||
this.body = body; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("Email{to=%s, body=%s}", getTo(), getBody()); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/gwangjang/server/global/rabbitMQ/EmailMsgSender.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,31 @@ | ||
package gwangjang.server.global.rabbitMQ; | ||
|
||
import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; | ||
import gwangjang.server.domain.subscribe.domain.service.SubscribeQueryService; | ||
import org.springframework.amqp.core.TopicExchange; | ||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class EmailMsgSender { | ||
|
||
@Autowired | ||
private RabbitTemplate rabbitTemplate; | ||
@Autowired | ||
private SubscribeQueryService subscribeQueryService; | ||
|
||
@Autowired | ||
private TopicExchange topic; | ||
|
||
public void sendEmail(String routingKey, Email email){ | ||
rabbitTemplate.convertAndSend(topic.getName(), routingKey, email); | ||
} | ||
public void sendSubscribeData(String routingKey) { | ||
List<SubscribeData> subscribeDataList = subscribeQueryService.getIssueBySubscribers(); | ||
SubscribeDataMessage message = new SubscribeDataMessage(subscribeDataList); | ||
rabbitTemplate.convertAndSend(topic.getName(), routingKey, message); | ||
} | ||
} |
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
31 changes: 0 additions & 31 deletions
31
src/main/java/gwangjang/server/global/rabbitMQ/Receiver.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/gwangjang/server/global/rabbitMQ/SubscribeDataMessage.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 gwangjang.server.global.rabbitMQ; | ||
|
||
import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
public class SubscribeDataMessage implements Serializable { | ||
private List<SubscribeData> subscribeDataList; | ||
|
||
public SubscribeDataMessage() { | ||
// Default constructor needed for deserialization | ||
} | ||
|
||
public SubscribeDataMessage(List<SubscribeData> subscribeDataList) { | ||
this.subscribeDataList = subscribeDataList; | ||
} | ||
|
||
public List<SubscribeData> getSubscribeDataList() { | ||
return subscribeDataList; | ||
} | ||
|
||
public void setSubscribeDataList(List<SubscribeData> subscribeDataList) { | ||
this.subscribeDataList = subscribeDataList; | ||
} | ||
} |