Skip to content

Commit 57596c6

Browse files
EddieChoChogaryrussell
authored andcommitted
Add ReturnsCallback XML Configuration
1 parent 312d6a3 commit 57596c6

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/TemplateParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,6 +67,8 @@ class TemplateParser extends AbstractSingleBeanDefinitionParser {
6767

6868
private static final String RETURN_CALLBACK_ATTRIBUTE = "return-callback";
6969

70+
private static final String RETURNS_CALLBACK_ATTRIBUTE = "returns-callback";
71+
7072
private static final String CONFIRM_CALLBACK_ATTRIBUTE = "confirm-callback";
7173

7274
private static final String CORRELATION_KEY = "correlation-key";
@@ -122,6 +124,7 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit
122124
NamespaceUtils.setValueIfAttributeDefined(builder, element, USE_TEMPORARY_REPLY_QUEUES_ATTRIBUTE);
123125
NamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_ADDRESS_ATTRIBUTE);
124126
NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURN_CALLBACK_ATTRIBUTE);
127+
NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURNS_CALLBACK_ATTRIBUTE);
125128
NamespaceUtils.setReferenceIfAttributeDefined(builder, element, CONFIRM_CALLBACK_ATTRIBUTE);
126129
NamespaceUtils.setValueIfAttributeDefined(builder, element, CORRELATION_KEY);
127130
NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETRY_TEMPLATE);

spring-rabbit/src/main/resources/org/springframework/amqp/rabbit/config/spring-rabbit.xsd

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@
12851285
<xsd:annotation>
12861286
<xsd:documentation><![CDATA[
12871287
When 'true' sets the mandatory flag on basic.publish; only applies if
1288-
a 'return-callback' is provided. Mutually exclusive with 'mandatory-expression'.
1288+
a 'returns-callback' is provided. Mutually exclusive with 'mandatory-expression'.
12891289
Defaults to 'false'.
12901290
]]></xsd:documentation>
12911291
</xsd:annotation>
@@ -1299,7 +1299,7 @@
12991299
A SpEL expression to be evaluated against each request message to determine a 'mandatory' boolean value.
13001300
The BeanFactoryResolver is available too, if the RabbitTemplate is used from Spring Context,
13011301
allowing for expressions such as '@myBean.isMandatory(#root)`.
1302-
Only applies if a 'return-callback' is provided. Mutually exclusive with 'mandatory'.
1302+
Only applies if a 'returns-callback' is provided. Mutually exclusive with 'mandatory'.
13031303
]]></xsd:documentation>
13041304
</xsd:annotation>
13051305
</xsd:attribute>
@@ -1309,10 +1309,26 @@
13091309
A reference to an implementation of RabbitTemplate.ReturnCallback - invoked if
13101310
a return is received for a message published with mandatory set
13111311
that couldn't be delivered according to the semantics of that option.
1312+
DEPRECTATED - use 'returns-callback' instead.
13121313
]]></xsd:documentation>
13131314
<xsd:appinfo>
13141315
<tool:annotation kind="ref">
1315-
<tool:expected-type type="org.springframework.amqp.core.RabbitTemplate.ReturnCallback" />
1316+
<tool:expected-type type="org.springframework.amqp.core.RabbitTemplate.ReturnCallback"/>
1317+
</tool:annotation>
1318+
</xsd:appinfo>
1319+
</xsd:annotation>
1320+
</xsd:attribute>
1321+
<xsd:attribute name="returns-callback" type="xsd:string" use="optional">
1322+
<xsd:annotation>
1323+
<xsd:documentation><![CDATA[
1324+
A reference to an implementation of RabbitTemplate.ReturnsCallback - invoked if
1325+
a return is received for a message published with mandatory set
1326+
that couldn't be delivered according to the semantics of that option.
1327+
Replaces the deprecated 'return-callback'.
1328+
]]></xsd:documentation>
1329+
<xsd:appinfo>
1330+
<tool:annotation kind="ref">
1331+
<tool:expected-type type="org.springframework.amqp.core.RabbitTemplate.ReturnsCallback"/>
13161332
</tool:annotation>
13171333
</xsd:appinfo>
13181334
</xsd:annotation>
@@ -1326,7 +1342,7 @@
13261342
]]></xsd:documentation>
13271343
<xsd:appinfo>
13281344
<tool:annotation kind="ref">
1329-
<tool:expected-type type="org.springframework.amqp.core.RabbitTemplate.ConfirmCallback" />
1345+
<tool:expected-type type="org.springframework.amqp.core.RabbitTemplate.ConfirmCallback"/>
13301346
</tool:annotation>
13311347
</xsd:appinfo>
13321348
</xsd:annotation>

spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/TemplateParserTests-context.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434

3535
<rabbit:template id="withCallbacks" connection-factory="connectionFactory"
3636
direct-reply-to-container="false"
37-
mandatory="true" return-callback="rcb" confirm-callback="ccb"/>
37+
mandatory="true" returns-callback="rcb" confirm-callback="ccb"/>
3838

3939
<rabbit:template id="withMandatoryExpression" connection-factory="connectionFactory"
4040
mandatory-expression="'true'"
4141
send-connection-factory-selector-expression="'foo'"
4242
receive-connection-factory-selector-expression="'foo'"/>
4343

4444
<bean id="rcb" class="org.mockito.Mockito" factory-method="mock">
45-
<constructor-arg value="org.springframework.amqp.rabbit.core.RabbitTemplate$ReturnCallback"/>
45+
<constructor-arg value="org.springframework.amqp.rabbit.core.RabbitTemplate$ReturnsCallback"/>
4646
</bean>
4747

4848
<bean id="ccb" class="org.mockito.Mockito" factory-method="mock">

0 commit comments

Comments
 (0)