Update dependencies; prepare for release

* Adapt AMQP module for the latest Spring AMQP changes
This commit is contained in:
Artem Bilan
2023-10-16 15:27:14 -04:00
parent 68f977a588
commit 3fc372b68e
3 changed files with 62 additions and 35 deletions

View File

@@ -15,11 +15,11 @@ buildscript {
}
plugins {
id 'org.sonarqube' version '4.3.0.3225'
id 'org.sonarqube' version '4.4.1.3373'
id 'io.spring.nohttp' version '0.0.11' apply false
id 'org.ajoberstar.grgit' version '4.1.1'
id 'io.spring.dependency-management' version '1.1.2'
id 'com.jfrog.artifactory' version '4.33.1' apply false
id 'io.spring.dependency-management' version '1.1.3'
id 'com.jfrog.artifactory' version '5.1.10' apply false
id 'org.jetbrains.dokka' version "$kotlinVersion"
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
@@ -52,9 +52,9 @@ ext {
aspectjVersion = '1.9.20.1'
assertjVersion = '3.24.2'
assertkVersion = '0.26.1'
avroVersion = '1.11.2'
avroVersion = '1.11.3'
awaitilityVersion = '4.2.0'
camelVersion = '3.20.6'
camelVersion = '3.20.7'
commonsDbcp2Version = '2.9.0'
commonsIoVersion = '2.11.0'
commonsNetVersion = '3.9.0'
@@ -67,13 +67,13 @@ ext {
groovyVersion = '4.0.15'
hamcrestVersion = '2.2'
hazelcastVersion = '5.2.4'
hibernateVersion = '6.2.8.Final'
hibernateVersion = '6.2.13.Final'
hsqldbVersion = '2.7.2'
h2Version = '2.2.224'
jacksonVersion = '2.15.2'
jacksonVersion = '2.15.3'
jaxbVersion = '4.0.3'
jcifsVersion = '2.1.36'
jeroMqVersion = '0.5.3'
jeroMqVersion = '0.5.4'
jmsApiVersion = '3.1.0'
jpaApiVersion = '3.1.0'
jrubyVersion = '9.4.3.0'
@@ -83,11 +83,11 @@ ext {
jythonVersion = '2.7.3'
kotlinCoroutinesVersion = '1.6.4'
kryoVersion = '5.5.0'
lettuceVersion = '6.2.4.RELEASE'
lettuceVersion = '6.2.6.RELEASE'
log4jVersion = '2.20.0'
mailVersion = '1.0.0'
micrometerTracingVersion = '1.1.5'
micrometerVersion = '1.11.4'
micrometerTracingVersion = '1.1.6'
micrometerVersion = '1.11.5'
mockitoVersion = '5.3.1'
mongoDriverVersion = '4.9.1'
mysqlVersion = '8.0.33'
@@ -96,22 +96,22 @@ ext {
postgresVersion = '42.6.0'
protobufVersion = '3.23.4'
r2dbch2Version = '1.0.0.RELEASE'
reactorVersion = '2022.0.11'
reactorVersion = '2022.0.1'
resilience4jVersion = '2.0.2'
romeToolsVersion = '2.1.0'
rsocketVersion = '1.1.4'
servletApiVersion = '6.0.0'
smackVersion = '4.4.6'
springAmqpVersion = '3.0.9'
springDataVersion = '2023.0.4'
springAmqpVersion = '3.0.10'
springDataVersion = '2023.0.5'
springGraphqlVersion = '1.2.3'
springKafkaVersion = '3.0.11'
springRetryVersion = '2.0.3'
springSecurityVersion = '6.1.4'
springVersion = '6.0.12'
springKafkaVersion = '3.0.12'
springRetryVersion = '2.0.4'
springSecurityVersion = '6.1.5'
springVersion = '6.0.13'
springWsVersion = '4.0.6'
testcontainersVersion = '1.19.0'
tomcatVersion = '10.1.13'
testcontainersVersion = '1.19.1'
tomcatVersion = '10.1.14'
xmlUnitVersion = '2.9.1'
xstreamVersion = '1.4.20'
ztZipVersion = '1.16'

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,11 +23,20 @@ import org.springframework.amqp.rabbit.connection.Connection;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
import org.springframework.integration.amqp.support.MappingUtils;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.AdviceMessage;
import org.springframework.integration.support.MutableMessage;
import org.springframework.integration.support.MutableMessageHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.util.Assert;
/**
@@ -87,6 +96,19 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel impleme
this.amqpTemplate = amqpTemplate;
if (amqpTemplate instanceof RabbitTemplate) {
this.rabbitTemplate = (RabbitTemplate) amqpTemplate;
MessageConverter converter = this.rabbitTemplate.getMessageConverter();
if (converter instanceof AllowedListDeserializingMessageConverter allowedListMessageConverter) {
allowedListMessageConverter.addAllowedListPatterns(
"java.util*",
"java.lang*",
GenericMessage.class.getName(),
ErrorMessage.class.getName(),
AdviceMessage.class.getName(),
MutableMessage.class.getName(),
MessageHeaders.class.getName(),
MutableMessageHeaders.class.getName(),
MessageHistory.class.getName());
}
}
else {
this.rabbitTemplate = null;
@@ -143,7 +165,7 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel impleme
/**
* When mapping headers for the outbound message, determine whether the headers are
* mapped before the message is converted, or afterwards. This only affects headers
* mapped before the message is converted, or afterward. This only affects headers
* that might be added by the message converter. When false, the converter's headers
* win; when true, any headers added by the converter will be overridden (if the
* source message has a header that maps to those headers). You might wish to set this
@@ -242,10 +264,6 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel impleme
doDeclares();
}
@Override
public void onClose(Connection connection) {
}
protected abstract void doDeclares();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.amqp.AmqpConnectException;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
@@ -77,6 +78,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
*/
protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
AmqpTemplate amqpTemplate) {
this(channelName, container, amqpTemplate, false);
}
@@ -93,6 +95,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
*/
protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) {
this(channelName, container, amqpTemplate, false, outboundMapper, inboundMapper);
}
@@ -108,6 +111,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
protected AbstractSubscribableAmqpChannel(String channelName,
AbstractMessageListenerContainer container,
AmqpTemplate amqpTemplate, boolean isPubSub) {
this(channelName, container, amqpTemplate, isPubSub,
DefaultAmqpHeaderMapper.outboundMapper(), DefaultAmqpHeaderMapper.inboundMapper());
}
@@ -128,14 +132,16 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
AbstractMessageListenerContainer container,
AmqpTemplate amqpTemplate, boolean isPubSub,
AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) {
super(amqpTemplate, outboundMapper, inboundMapper);
Assert.notNull(container, "container must not be null");
Assert.hasText(channelName, "channel name must not be empty");
this.channelName = channelName;
this.container = container;
this.isPubSub = isPubSub;
setConnectionFactory(container.getConnectionFactory());
setAdmin(new RabbitAdmin(getConnectionFactory()));
ConnectionFactory connectionFactory = container.getConnectionFactory();
setConnectionFactory(connectionFactory);
setAdmin(new RabbitAdmin(connectionFactory));
}
/**
@@ -173,11 +179,13 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
setMaxSubscribers(this.maxSubscribers);
String queue = obtainQueueName(this.channelName);
this.container.setQueueNames(queue);
MessageConverter converter = (this.getAmqpTemplate() instanceof RabbitTemplate)
? ((RabbitTemplate) this.getAmqpTemplate()).getMessageConverter()
MessageConverter converter =
(getAmqpTemplate() instanceof RabbitTemplate rabbitTemplate)
? rabbitTemplate.getMessageConverter()
: new SimpleMessageConverter();
MessageListener listener = new DispatchingMessageListener(converter,
this.dispatcher, this, this.isPubSub,
MessageListener listener =
new DispatchingMessageListener(converter, this.dispatcher, this, this.isPubSub,
getMessageBuilderFactory(), getInboundHeaderMapper());
this.container.setMessageListener(listener);
if (!this.container.isActive()) {
@@ -256,7 +264,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
private static final class DispatchingMessageListener implements MessageListener {
private final Log logger = LogFactory.getLog(this.getClass());
private final Log logger = LogFactory.getLog(DispatchingMessageListener.class);
private final MessageDispatcher dispatcher;
@@ -273,6 +281,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
private DispatchingMessageListener(MessageConverter converter,
MessageDispatcher dispatcher, AbstractSubscribableAmqpChannel channel, boolean isPubSub,
MessageBuilderFactory messageBuilderFactory, AmqpHeaderMapper inboundHeaderMapper) {
Assert.notNull(converter, "MessageConverter must not be null");
Assert.notNull(dispatcher, "MessageDispatcher must not be null");
this.converter = converter;
@@ -308,7 +317,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
}
}
protected Message<Object> buildMessage(org.springframework.amqp.core.Message message, Object converted) {
private Message<Object> buildMessage(org.springframework.amqp.core.Message message, Object converted) {
AbstractIntegrationMessageBuilder<Object> messageBuilder =
this.messageBuilderFactory.withPayload(converted);
if (this.channel.isExtractPayload()) {