From 999878f0480cc43f4f6413aad82757d806af06b0 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Tue, 22 Jul 2014 23:44:36 -0400 Subject: [PATCH] INTEXT-104: Kafka: `order` for o-channel-adapter JIRA: https://jira.spring.io/browse/INTEXT-104 `order` attribute now honored if kafka outbound adapter is connected to a subscribable channel unit tests and samples are updated Polishing: use `` for adapter tags to cover `SmartLifecycle` options. --- .../xml/spring-integration-kafka-1.0.xsd | 76 +++---------------- ...afkaOutboundAdapterParserTests-context.xml | 1 + .../xml/KafkaOutboundAdapterParserTests.java | 14 ++-- 3 files changed, 20 insertions(+), 71 deletions(-) diff --git a/spring-integration-kafka/src/main/resources/org/springframework/integration/config/xml/spring-integration-kafka-1.0.xsd b/spring-integration-kafka/src/main/resources/org/springframework/integration/config/xml/spring-integration-kafka-1.0.xsd index 866255f2f4..92a4e1b6c1 100644 --- a/spring-integration-kafka/src/main/resources/org/springframework/integration/config/xml/spring-integration-kafka-1.0.xsd +++ b/spring-integration-kafka/src/main/resources/org/springframework/integration/config/xml/spring-integration-kafka-1.0.xsd @@ -9,7 +9,7 @@ + schemaLocation="http://www.springframework.org/schema/integration/spring-integration-4.0.xsd"/> - - - - - - - - - - + - + Kafka Server Bean Name @@ -430,30 +420,6 @@ - - - - - Identifies the underlying Spring bean definition, which is an - instance of either 'EventDrivenConsumer' or 'PollingConsumer', - depending on whether the component's input channel is a - 'SubscribableChannel' or 'PollableChannel'. - - - - - - - Flag to indicate that the component should start automatically - on startup (default true). - - - - - - - - @@ -466,42 +432,20 @@ - - - - Identifies the underlying Spring bean definition, which is an - instance of either 'EventDrivenConsumer' or 'PollingConsumer', - depending on whether the component's input channel is a - 'SubscribableChannel' or 'PollableChannel'. - - - - - - - Flag to indicate that the component should start automatically - on startup (default true). - - - - - - - + + Kafka producer context reference. - + - - - - - + + Specifies the order for invocation when this endpoint is connected as a + subscriber to a SubscribableChannel. + diff --git a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests-context.xml b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests-context.xml index 89df6ff229..d1cdd05443 100644 --- a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests-context.xml +++ b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests-context.xml @@ -17,6 +17,7 @@ kafka-producer-context-ref="kafkaProducerContext" auto-startup="false" channel="inputToKafka" + order="3" > diff --git a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java index d2b0909cb6..6e2f56440f 100644 --- a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java +++ b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java @@ -18,6 +18,7 @@ package org.springframework.integration.kafka.config.xml; import org.junit.Assert; 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.endpoint.PollingConsumer; @@ -32,20 +33,23 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration -public class KafkaOutboundAdapterParserTests { +public class KafkaOutboundAdapterParserTests { @Autowired private ApplicationContext appContext; @Test @SuppressWarnings("unchecked") - public void testOutboundAdapterConfiguration(){ - final PollingConsumer pollingConsumer = appContext.getBean("kafkaOutboundChannelAdapter", PollingConsumer.class); - final KafkaProducerMessageHandler messageHandler = appContext.getBean(KafkaProducerMessageHandler.class); + public void testOutboundAdapterConfiguration() { + final PollingConsumer pollingConsumer = + appContext.getBean("kafkaOutboundChannelAdapter", PollingConsumer.class); + final KafkaProducerMessageHandler messageHandler = appContext.getBean(KafkaProducerMessageHandler.class); Assert.assertNotNull(pollingConsumer); Assert.assertNotNull(messageHandler); - final KafkaProducerContext producerContext = messageHandler.getKafkaProducerContext(); + Assert.assertEquals(messageHandler.getOrder(), 3); + final KafkaProducerContext producerContext = messageHandler.getKafkaProducerContext(); Assert.assertNotNull(producerContext); Assert.assertEquals(producerContext.getTopicsConfiguration().size(), 2); } + }