forked from HamaHama-Dev/pupmory
-
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.
feat: Add RabbitMQ WcGen config (#4)
Co-authored-by: chaeeun-Han <[email protected]> Co-authored-by: Queue-ri <[email protected]> Co-authored-by: hyojeongchoi <[email protected]>
- Loading branch information
1 parent
71ddb0c
commit 5886214
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
backend/src/main/java/com/hamahama/pupmory/conf/RabbitWcGenConfig.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,48 @@ | ||
package com.hamahama.pupmory.conf; | ||
|
||
import org.springframework.amqp.core.Binding; | ||
import org.springframework.amqp.core.BindingBuilder; | ||
import org.springframework.amqp.core.Queue; | ||
import org.springframework.amqp.core.TopicExchange; | ||
import org.springframework.amqp.rabbit.connection.ConnectionFactory; | ||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; | ||
import org.springframework.amqp.support.converter.MessageConverter; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class RabbitWcGenConfig { | ||
private static final String queueName = "pupmory.wcgen"; | ||
private static final String topicExchangeName = "pupmory.wcgen.exchange"; | ||
|
||
@Bean | ||
Queue queue() { | ||
return new Queue(queueName, false); | ||
} | ||
|
||
@Bean | ||
TopicExchange exchange() { | ||
return new TopicExchange(topicExchangeName); | ||
} | ||
|
||
@Bean | ||
Binding binding(Queue queue, TopicExchange exchange) { | ||
return BindingBuilder.bind(queue).to(exchange).with("pupmory.wcgen"); | ||
} | ||
|
||
@Bean | ||
RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory, | ||
MessageConverter messageConverter) { | ||
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); | ||
rabbitTemplate.setReplyTimeout(300000); | ||
rabbitTemplate.setReceiveTimeout(300000); | ||
rabbitTemplate.setMessageConverter(messageConverter); | ||
return rabbitTemplate; | ||
} | ||
|
||
@Bean | ||
MessageConverter messageConverter() { | ||
return new Jackson2JsonMessageConverter(); | ||
} | ||
} |