Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
INT-2822: deprecate 'ignore-empty-responses'
* Add 'requires-reply' section into What's New
  • Loading branch information
artembilan committed Aug 16, 2013
1 parent b866f9c commit c4c5b69
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 32 deletions.
Expand Up @@ -70,8 +70,6 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro

private volatile WebServiceMessageCallback requestCallback;

private volatile boolean ignoreEmptyResponses = true;

protected volatile SoapHeaderMapper headerMapper = new DefaultSoapHeaderMapper();

public AbstractWebServiceOutboundGateway(final String uri, WebServiceMessageFactory messageFactory) {
Expand Down Expand Up @@ -111,12 +109,12 @@ public void setReplyChannel(MessageChannel replyChannel) {
}

/**
* Specify whether empty String response payloads should be ignored.
* The default is <code>true</code>. Set this to <code>false</code> if
* you want to send empty String responses in reply Messages.
* Backward compatibility - with no op.
* @deprecated in favor of {@link #setRequiresReply(boolean)}
*/
@Deprecated
public void setIgnoreEmptyResponses(boolean ignoreEmptyResponses) {
this.ignoreEmptyResponses = ignoreEmptyResponses;
//No-op
}

public void setMessageFactory(WebServiceMessageFactory messageFactory) {
Expand Down Expand Up @@ -167,15 +165,7 @@ public final Object handleRequestMessage(Message<?> requestMessage) {
throw new MessageDeliveryException(requestMessage, "Failed to determine URI for " +
"Web Service request in outbound gateway: " + this.getComponentName());
}
Object responsePayload = this.doHandle(uri.toString(), requestMessage, this.requestCallback);
if (responsePayload != null) {
boolean shouldIgnore = (this.ignoreEmptyResponses
&& responsePayload instanceof String && !StringUtils.hasText((String) responsePayload));
if (!shouldIgnore) {
return responsePayload;
}
}
return null;
return this.doHandle(uri.toString(), requestMessage, this.requestCallback);
}

protected abstract Object doHandle(String uri, Message<?> requestMessage, WebServiceMessageCallback requestCallback);
Expand Down
Expand Up @@ -148,8 +148,7 @@
<xsd:attribute name="ignore-empty-responses" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Indicates whether empty String response payloads should be ignored. The default is TRUE.
Set this to FALSE if you want to send empty String responses in reply Messages.
[DEPRECATED] with 'no-op' in favor of 'requires-reply' attribute.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
Expand Down
Expand Up @@ -88,28 +88,15 @@ public void simpleGatewayWithReplyChannel() {
assertEquals(Long.valueOf(777), sendTimeout);
}

@Test
public void simpleGatewayWithIgnoreEmptyResponseTrueByDefault() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithReplyChannel");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreEmptyResponses"));
}

@Test
public void simpleGatewayWithIgnoreEmptyResponses() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithIgnoreEmptyResponsesFalse");
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithRequiresReplyTrue");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(Boolean.FALSE, accessor.getPropertyValue("ignoreEmptyResponses"));
Assert.assertEquals(Boolean.TRUE, accessor.getPropertyValue("requiresReply"));
}

Expand Down
Expand Up @@ -31,7 +31,7 @@
mapped-request-headers="testRequest"
mapped-reply-headers="testReply"/>

<ws:outbound-gateway id="gatewayWithIgnoreEmptyResponsesFalse"
<ws:outbound-gateway id="gatewayWithRequiresReplyTrue"
request-channel="inputChannel"
uri="http://example.org"
ignore-empty-responses="false"
Expand Down
17 changes: 17 additions & 0 deletions src/reference/docbook/whats-new.xml
Expand Up @@ -223,6 +223,23 @@
<para>
For more information see <xref linkend="stored-procedures"/>.
</para>
</section> <title>'requires-reply' attribute for Outbound Gateways</title>
<para>
All Outbound Gateways (e.g. <code>&lt;ftp:outbound-gateway/&gt;</code> or <code>&lt;jms:outbound-gateway/&gt;</code>)
are designed for 'request-reply' scenario. In this case we are expecting that response from external service
will be published to the <code>reply-channel</code>. But there are many cases where external system doesn't
return result, e.g. <code>&lt;jdbc:outbound-gateway/&gt;</code>, when SELECT ends with empty <interfacename>ResultSet</interfacename>
or the underlying Web Service is One-Way. So, we need an option when we can decide do not expect <emphasis>reply</emphasis>.
For this purpose <emphasis>requires-reply</emphasis> attribute was introduced for all Outbound Gateway components.
In most cases default value for <emphasis>requires-reply</emphasis> is <code>true</code> and if there is no any result
<classname>ReplyRequiredException</classname> will be thrown. Change it to <code>false</code>
means that, if an external service doesn't return anything, the message-flow will end on current Outbound Gateway,
similar to Outbound Channel Adapter.
</para>
<para>
Note, the <code>requiresReply</code> property is presented in the <classname>AbstractReplyProducingMessageHandler</classname>
but with value <code>false</code> and there wasn't any configuration ability on Outbound Gateways to change it before this release.
</para>
</section>
<section id="3.0-event-for-imap-idle">
<title>IMAP Idle Connection Exceptions</title>
Expand Down

0 comments on commit c4c5b69

Please sign in to comment.