Results 1 to 3 of 3

Thread: inbound-channel-adapter's auto-startup feature is not working

  1. #1
    Join Date
    Jan 2010
    Posts
    9

    Default inbound-channel-adapter's auto-startup feature is not working

    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:

    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>
    Here is my main program:


    Code:
    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();
    		}
    	}
    
    }
    I attached the maven project too. Please help

    Thanks,
    sashi202
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    When you call start() on the context, that will start any Lifecycle bean. What "auto" startup means is that the bean will start itself even without the call being made. So, can you try just removing your call to start()?

  3. #3
    Join Date
    Jan 2010
    Posts
    9

    Default

    Mark,

    It works. I misunderstood the auto startup feature. Thank you for the prompt response.

    sashi202

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •