Enable secure connections via 'spring.rabbitmq.ssl.enabled' will be considered now (#394)
Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
92dd6a1a0e
commit
ccc23bf634
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -81,7 +82,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the bean for the custom error handler.
|
* Register the bean for the custom error handler.
|
||||||
*
|
*
|
||||||
* @return custom error handler
|
* @return custom error handler
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -109,19 +110,26 @@ public class AmqpConfiguration {
|
|||||||
/**
|
/**
|
||||||
* {@link ConnectionFactory} with enabled publisher confirms and
|
* {@link ConnectionFactory} with enabled publisher confirms and
|
||||||
* heartbeat.
|
* heartbeat.
|
||||||
*
|
*
|
||||||
* @param config
|
* @param config
|
||||||
* with standard {@link RabbitProperties}
|
* with standard {@link RabbitProperties}
|
||||||
* @return {@link ConnectionFactory}
|
* @return {@link ConnectionFactory}
|
||||||
|
* @throws GeneralSecurityException
|
||||||
|
* in case of problems with enabled SSL connections
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ConnectionFactory rabbitConnectionFactory(final RabbitProperties config) {
|
public ConnectionFactory rabbitConnectionFactory(final RabbitProperties config)
|
||||||
|
throws GeneralSecurityException {
|
||||||
final CachingConnectionFactory factory = new CachingConnectionFactory();
|
final CachingConnectionFactory factory = new CachingConnectionFactory();
|
||||||
factory.setRequestedHeartBeat(amqpProperties.getRequestedHeartBeat());
|
factory.setRequestedHeartBeat(amqpProperties.getRequestedHeartBeat());
|
||||||
factory.setExecutor(threadPoolExecutor);
|
factory.setExecutor(threadPoolExecutor);
|
||||||
factory.getRabbitConnectionFactory().setHeartbeatExecutor(scheduledExecutorService);
|
factory.getRabbitConnectionFactory().setHeartbeatExecutor(scheduledExecutorService);
|
||||||
factory.setPublisherConfirms(true);
|
factory.setPublisherConfirms(true);
|
||||||
|
|
||||||
|
if (config.getSsl().isEnabled()) {
|
||||||
|
factory.getRabbitConnectionFactory().useSslProtocol();
|
||||||
|
}
|
||||||
|
|
||||||
final String addresses = config.getAddresses();
|
final String addresses = config.getAddresses();
|
||||||
factory.setAddresses(addresses);
|
factory.setAddresses(addresses);
|
||||||
if (config.getHost() != null) {
|
if (config.getHost() != null) {
|
||||||
@@ -144,7 +152,7 @@ public class AmqpConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Create a {@link RabbitAdmin} and ignore declaration exceptions.
|
* Create a {@link RabbitAdmin} and ignore declaration exceptions.
|
||||||
* {@link RabbitAdmin#setIgnoreDeclarationExceptions(boolean)}
|
* {@link RabbitAdmin#setIgnoreDeclarationExceptions(boolean)}
|
||||||
*
|
*
|
||||||
* @return the bean
|
* @return the bean
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -276,7 +284,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create AMQP handler service bean.
|
* Create AMQP handler service bean.
|
||||||
*
|
*
|
||||||
* @param rabbitTemplate
|
* @param rabbitTemplate
|
||||||
* for converting messages
|
* for converting messages
|
||||||
* @param amqpMessageDispatcherService
|
* @param amqpMessageDispatcherService
|
||||||
@@ -298,7 +306,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create AMQP handler service bean for authentication messages.
|
* Create AMQP handler service bean for authentication messages.
|
||||||
*
|
*
|
||||||
* @param rabbitTemplate
|
* @param rabbitTemplate
|
||||||
* for converting messages
|
* for converting messages
|
||||||
* @param authenticationManager
|
* @param authenticationManager
|
||||||
@@ -335,7 +343,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Listener factory.
|
* Returns the Listener factory.
|
||||||
*
|
*
|
||||||
* @param errorHandler
|
* @param errorHandler
|
||||||
* the error hander
|
* the error hander
|
||||||
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
||||||
@@ -349,7 +357,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* create the authentication bean for controller over amqp.
|
* create the authentication bean for controller over amqp.
|
||||||
*
|
*
|
||||||
* @param systemManagement
|
* @param systemManagement
|
||||||
* the systemManagement
|
* the systemManagement
|
||||||
* @param controllerManagement
|
* @param controllerManagement
|
||||||
@@ -376,7 +384,7 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dispatcher bean.
|
* Create the dispatcher bean.
|
||||||
*
|
*
|
||||||
* @param rabbitTemplate
|
* @param rabbitTemplate
|
||||||
* the rabbitTemplate
|
* the rabbitTemplate
|
||||||
* @param amqpSenderService
|
* @param amqpSenderService
|
||||||
|
|||||||
Reference in New Issue
Block a user