Merge pull request #86 from bsinno/CREATE_RABBIT_TEAMPLATE_BEAN
Thx for the contribution
This commit is contained in:
@@ -21,7 +21,6 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
@@ -31,8 +30,6 @@ import org.springframework.context.annotation.Bean;
|
|||||||
* The spring AMQP configuration which is enabled by using the profile
|
* The spring AMQP configuration which is enabled by using the profile
|
||||||
* {@code amqp} to use a AMQP for communication with SP enabled devices.
|
* {@code amqp} to use a AMQP for communication with SP enabled devices.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@EnableConfigurationProperties(AmqpProperties.class)
|
@EnableConfigurationProperties(AmqpProperties.class)
|
||||||
public class AmqpConfiguration {
|
public class AmqpConfiguration {
|
||||||
@@ -43,19 +40,16 @@ public class AmqpConfiguration {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ConnectionFactory connectionFactory;
|
private ConnectionFactory connectionFactory;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitTemplate rabbitTemplate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to set the Jackson2JsonMessageConverter.
|
* Method to set the Jackson2JsonMessageConverter.
|
||||||
*
|
*
|
||||||
* @return the Jackson2JsonMessageConverter
|
* @return the Jackson2JsonMessageConverter
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MessageConverter jsonMessageConverter() {
|
public RabbitTemplate rabbitTemplate() {
|
||||||
final Jackson2JsonMessageConverter jackson2JsonMessageConverter = new Jackson2JsonMessageConverter();
|
final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
|
||||||
rabbitTemplate.setMessageConverter(jackson2JsonMessageConverter);
|
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||||
return jackson2JsonMessageConverter;
|
return rabbitTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +120,7 @@ public class AmqpConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public AmqpMessageHandlerService amqpMessageHandlerService() {
|
public AmqpMessageHandlerService amqpMessageHandlerService() {
|
||||||
return new AmqpMessageHandlerService(rabbitTemplate);
|
return new AmqpMessageHandlerService(rabbitTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +131,7 @@ public class AmqpConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public AmqpSenderService amqpSenderServiceBean() {
|
public AmqpSenderService amqpSenderServiceBean() {
|
||||||
return new DefaultAmqpSenderService(rabbitTemplate);
|
return new DefaultAmqpSenderService(rabbitTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user