Hi,
I want the inbound-channel-adapter in disabled mode when the spring context is started.
Application will start up the endpoint later.
To accomplish that I set my inbound-channel-adapter's auto-startup to false in spring context file.
But it is not working. Spring is simply ignoring the auto-startup setting and starting the endpoint.
However I was able to stop the endpoint later by calling Lifecycle.stop, but I do not want the endpoint started when the app is started.
Here is my spring context file:
Here is my main program:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"> <bean id="uuidBean" class="java.util.UUID" factory-method="randomUUID"/> <int:inbound-channel-adapter id="uuidGenerator" auto-startup="false" channel="uuidChannel" ref="uuidBean" method="randomUUID"> <int:poller fixed-delay="1000" /> </int:inbound-channel-adapter> <bean id="java.lang.System.out" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/> <int:service-activator ref="java.lang.System.out" method="println" input-channel="uuidChannel"/> </beans>
I attached the maven project too. Please helpCode:package auto_startup; import org.springframework.context.Lifecycle; import org.springframework.context.support.ClassPathXmlApplicationContext; public class StartApp { public static void main(String[] args) { try { ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext("test-ctx.xml"); appCtx.start(); System.out.println("\nSleeping for 5 seconds\n"); Thread.sleep(5000); System.out.println("\nStopping the endpoint uuidGenerator\n"); Lifecycle lc = appCtx.getBean("uuidGenerator", Lifecycle.class); lc.stop(); System.out.println("\nSuccessfully stopped endpoint uuidGenerator.\n"); System.out.println("\nSleeping forever. You should not see any " + "UUID's on the console\n"); Thread.sleep(Long.MAX_VALUE); } catch(Exception e) { e.printStackTrace(); } } }
Thanks,
sashi202


Reply With Quote