Skip to content

Commit

Permalink
feat: Add RabbitMQ WcGen config (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: chaeeun-Han <[email protected]>
Co-authored-by: Queue-ri <[email protected]>
Co-authored-by: hyojeongchoi <[email protected]>
  • Loading branch information
4 people committed Mar 14, 2024
1 parent 71ddb0c commit 5886214
Showing 1 changed file with 48 additions and 0 deletions.
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();
}
}

0 comments on commit 5886214

Please sign in to comment.