diff --git a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd index 76f01df9d6..e56af8089a 100644 --- a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd +++ b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd @@ -72,6 +72,17 @@ + + + + Specifies the order for invocation when this endpoint is connected as a +subscriber to a channel. This is particularly relevant when that channel +is using a "failover" dispatching strategy, or when a failure in the delivery to one subscriber should signal that +the message should not be sent to subscribers with a higher 'order' attribute. It has no effect when this +endpoint itself is a Polling Consumer for a channel with a queue. + + + diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml index 6cea25ca97..8349f253ae 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml @@ -23,9 +23,20 @@ charset="UTF-8" remote-file-separator="." temporary-file-suffix=".foo" - remote-filename-generator="fileNameGenerator"/> + remote-filename-generator="fileNameGenerator" + order="23"/> - + + + diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests.java index 4ba20ae22f..de16b0b5b2 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * 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. @@ -19,11 +19,16 @@ package org.springframework.integration.ftp.config; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertSame; + +import java.util.Iterator; +import java.util.Set; import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.channel.PublishSubscribeChannel; +import org.springframework.integration.core.MessageHandler; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.file.remote.handler.FileTransferringMessageHandler; import org.springframework.integration.file.remote.session.CachingSessionFactory; @@ -32,6 +37,7 @@ import org.springframework.integration.test.util.TestUtils; /** * @author Oleg Zhurakousky + * @author Gary Russell * @since 2.0 */ public class FtpOutboundChannelAdapterParserTests { @@ -42,7 +48,8 @@ public class FtpOutboundChannelAdapterParserTests { new ClassPathXmlApplicationContext("FtpOutboundChannelAdapterParserTests-context.xml", this.getClass()); Object consumer = ac.getBean("ftpOutbound"); assertTrue(consumer instanceof EventDrivenConsumer); - assertEquals(ac.getBean("ftpChannel"), TestUtils.getPropertyValue(consumer, "inputChannel")); + PublishSubscribeChannel channel = ac.getBean("ftpChannel", PublishSubscribeChannel.class); + assertEquals(channel, TestUtils.getPropertyValue(consumer, "inputChannel")); assertEquals("ftpOutbound", ((EventDrivenConsumer)consumer).getComponentName()); FileTransferringMessageHandler handler = (FileTransferringMessageHandler) TestUtils.getPropertyValue(consumer, "handler"); String remoteFileSeparator = (String) TestUtils.getPropertyValue(handler, "remoteFileSeparator"); @@ -56,5 +63,15 @@ public class FtpOutboundChannelAdapterParserTests { DefaultFtpSessionFactory sf = (DefaultFtpSessionFactory) TestUtils.getPropertyValue(cacheSf, "sessionFactory"); assertEquals("localhost", TestUtils.getPropertyValue(sf, "host")); assertEquals(22, TestUtils.getPropertyValue(sf, "port")); + assertEquals(23, TestUtils.getPropertyValue(handler, "order")); + //verify subscription order + @SuppressWarnings("unchecked") + Set handlers = (Set) TestUtils + .getPropertyValue( + TestUtils.getPropertyValue(channel, "dispatcher"), + "handlers"); + Iterator iterator = handlers.iterator(); + assertSame(TestUtils.getPropertyValue(ac.getBean("ftpOutbound2"), "handler"), iterator.next()); + assertSame(handler, iterator.next()); } } diff --git a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd index f25a5df072..1a5884c983 100644 --- a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd +++ b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.0.xsd @@ -113,6 +113,17 @@ + + + + Specifies the order for invocation when this endpoint is connected as a +subscriber to a channel. This is particularly relevant when that channel +is using a "failover" dispatching strategy, or when a failure in the delivery to one subscriber should signal that +the message should not be sent to subscribers with a higher 'order' attribute. It has no effect when this +endpoint itself is a Polling Consumer for a channel with a queue. + + + diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml index fc37e11ad7..566de025e1 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml @@ -18,7 +18,7 @@ - + + remote-directory="foo/bar" + order="23"/> + remote-filename-generator-expression="payload.getName() + '-foo'" + order="12"/> handlers = (Set) TestUtils + .getPropertyValue( + TestUtils.getPropertyValue(channel, "dispatcher"), + "handlers"); + Iterator iterator = handlers.iterator(); + assertSame(TestUtils.getPropertyValue(context.getBean("sftpOutboundAdapterWithExpression"), "handler"), iterator.next()); + assertSame(handler, iterator.next()); } @Test