-
Notifications
You must be signed in to change notification settings - Fork 1
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 #65 from TC4Y-777/stage
Add RabbitMQ broker
- Loading branch information
Showing
68 changed files
with
5,127 additions
and
148 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
21 changes: 21 additions & 0 deletions
21
Tithe-Spring/src/main/java/com/tithe/client/rabbitmq/consumer/TempConsumer.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,21 @@ | ||
package com.tithe.client.rabbitmq.consumer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.amqp.rabbit.annotation.RabbitListener; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.tithe.entity.RelationEntity; | ||
|
||
@Service | ||
public class TempConsumer { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TempConsumer.class); | ||
|
||
@RabbitListener(queues = {"tempQueue"}) | ||
public void consume(RelationEntity relation) { | ||
LOGGER.info(String.format("Message Received: %s", relation)); | ||
|
||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
Tithe-Spring/src/main/java/com/tithe/client/rabbitmq/producer/TempProducer.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 com.tithe.client.rabbitmq.producer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.tithe.entity.RelationEntity; | ||
|
||
@Service | ||
public class TempProducer { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TempProducer.class); | ||
|
||
@Autowired | ||
private RabbitTemplate rabbitTemplate; | ||
|
||
public void sendMessage(String message) { | ||
RelationEntity relation = new RelationEntity(23L, "Niece"); | ||
LOGGER.info(String.format("Message sent: %s", relation)); | ||
|
||
rabbitTemplate.convertAndSend("tempTopicExchange", "tempQueueRoutingKey", relation); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
Tithe-Spring/src/main/java/com/tithe/config/RabbitMQConfig.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,56 @@ | ||
/** | ||
* | ||
*/ | ||
package com.tithe.config; | ||
|
||
import org.springframework.amqp.core.AmqpTemplate; | ||
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; | ||
|
||
/** | ||
* @author Ashish Sam T George | ||
* | ||
*/ | ||
@Configuration | ||
public class RabbitMQConfig { | ||
|
||
@Bean | ||
public Queue queue() { | ||
return new Queue("tempQueue"); | ||
} | ||
|
||
|
||
@Bean | ||
public TopicExchange exchange() { | ||
return new TopicExchange("tempTopicExchange"); | ||
} | ||
|
||
@Bean | ||
public Binding binding() { | ||
return BindingBuilder | ||
.bind(queue()) | ||
.to(exchange()) | ||
.with("tempQueueRoutingKey"); | ||
} | ||
|
||
@Bean | ||
public MessageConverter converter() { | ||
return new Jackson2JsonMessageConverter(); | ||
} | ||
|
||
@Bean | ||
public AmqpTemplate amqpTemplate(ConnectionFactory connectionFactory) { | ||
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); | ||
rabbitTemplate.setMessageConverter(converter()); | ||
return rabbitTemplate; | ||
} | ||
|
||
} |
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
Oops, something went wrong.