Merge pull request #204 from ghillert/INT-2258
In enricher: add setRequiresReply to XSD for the ContentEnricher. This attribute defaults to 'true'.
This commit is contained in:
@@ -46,7 +46,7 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout");
|
||||
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
|
||||
|
||||
List<Element> propertyElements = DomUtils.getChildElementsByTagName(element, "property");
|
||||
if (!CollectionUtils.isEmpty(propertyElements)) {
|
||||
|
||||
@@ -1132,6 +1132,29 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="requires-reply" use="optional" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
If you specify a 'request-channel' you can optionally set the
|
||||
'requires-reply' attribute as well. If you set this attribute to
|
||||
'true', a reply must return a non-null value.
|
||||
|
||||
For example, you dispatch a message to the request-channel
|
||||
(backed by a 'QueueChannel'). If the reply does not return within
|
||||
the specified 'replyTimeout', then the reply message will end up
|
||||
being Null.
|
||||
|
||||
By setting 'requires-reply' to 'true', a 'ReplyRequiredException'
|
||||
will be raised for null reply messages. If 'requires-reply' is set
|
||||
to false, those messages are silently dropped.
|
||||
|
||||
This attribute defaults to 'true', if not specified.]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="should-clone-payload">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -95,6 +96,17 @@ public class EnricherParserTests {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationCheckRequiresReply() {
|
||||
|
||||
Object endpoint = context.getBean("enricher");
|
||||
|
||||
boolean requiresReply = TestUtils.getPropertyValue(endpoint, "handler.requiresReply", Boolean.class);
|
||||
|
||||
assertTrue("Was expecting requiresReply to be 'false'", requiresReply);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integrationTest() {
|
||||
SubscribableChannel requests = context.getBean("requests", SubscribableChannel.class);
|
||||
@@ -114,7 +126,6 @@ public class EnricherParserTests {
|
||||
assertNotSame(original, enriched);
|
||||
}
|
||||
|
||||
|
||||
private static class Source {
|
||||
|
||||
private final String sourceName;
|
||||
@@ -129,7 +140,6 @@ public class EnricherParserTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Target implements Cloneable {
|
||||
|
||||
private volatile String name;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<channel id="input"/>
|
||||
|
||||
<channel id="output">
|
||||
<queue />
|
||||
</channel>
|
||||
|
||||
<channel id="requests"/>
|
||||
|
||||
<enricher id="enricher" input-channel="input"
|
||||
request-channel="requests" request-timeout="1234"
|
||||
reply-timeout="9876" requires-reply="false"
|
||||
order="99" should-clone-payload="true" output-channel="output">
|
||||
<property name="name" expression="payload.sourceName"/>
|
||||
<property name="age" value="42"/>
|
||||
</enricher>
|
||||
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class EnricherParserTests2 {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void configurationCheckRequiresReply() {
|
||||
|
||||
Object endpoint = context.getBean("enricher");
|
||||
|
||||
boolean requiresReply = TestUtils.getPropertyValue(endpoint, "handler.requiresReply", Boolean.class);
|
||||
|
||||
assertFalse("Was expecting requiresReply to be 'false'", requiresReply);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user