INT-1409 added support for 'send-timeout' on <bridge> elements

This commit is contained in:
Mark Fisher
2010-09-02 19:39:55 +00:00
parent 057454a79e
commit 8dd4231055
4 changed files with 23 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,8 +30,10 @@ public class BridgeParser extends AbstractConsumerEndpointParser {
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
return BeanDefinitionBuilder.genericBeanDefinition(
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".handler.BridgeHandler");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
return builder;
}
}

View File

@@ -659,6 +659,7 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="send-timeout" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

View File

@@ -34,5 +34,6 @@
<channel id="stopperChannel" />
<bridge input-channel="stopperChannel" />
<bridge id="bridgeWithSendTimeout" input-channel="bridgeWithSendTimeoutChannel" send-timeout="1234"/>
</beans:beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -20,13 +20,17 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.MessageChannelTemplate;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessagingException;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.BridgeHandler;
import org.springframework.integration.message.MessageBuilder;
import org.springframework.integration.message.StringMessage;
import org.springframework.test.context.ContextConfiguration;
@@ -59,6 +63,11 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
@Qualifier("output2")
private PollableChannel output2;
@Autowired
@Qualifier("bridgeWithSendTimeout")
private EventDrivenConsumer bridgeWithSendTimeout;
@Test
public void pollableChannel() {
Message<?> message = new StringMessage("test1");
@@ -90,4 +99,11 @@ public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
this.stopperChannel.send(message);
}
@Test
public void bridgeWithSendTimeout() {
BridgeHandler handler = (BridgeHandler) new DirectFieldAccessor(bridgeWithSendTimeout).getPropertyValue("handler");
MessageChannelTemplate template = (MessageChannelTemplate) new DirectFieldAccessor(handler).getPropertyValue("channelTemplate");
assertEquals(new Long(1234), new DirectFieldAccessor(template).getPropertyValue("sendTimeout"));
}
}