Announcement Announcement Module
Collapse
No announcement yet.
Keyboard as input source Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keyboard as input source

    Hi,

    I am trying to create a proof-of-concept Spring Integration application which reacts on input from the keyboard.

    The flow I am trying to create is:
    1. Receive input from keyboard
    2. Print input in console
    3. Append input to file

    I am however not sure about how to listing for keyboard input using Spring Integration.

    Can anyone help with a short example?

  • #2
    Here's a simple example for echoing from stdin to stdout:
    Code:
    <stream:stdin-channel-adapter channel="echo"/>
    
    <channel id="echo"/>
    
    <stream:stdout-channel-adapter channel="echo"/>

    Comment


    • #3
      Thank you, that was exactly what I was looking for.

      One last question:
      Which class implements the stdin-channel-adapter ?

      I would like to take a look at the source code.

      Comment


      • #4
        When adding:
        Code:
        <stream:stdin-channel-adapter channel="echo"/>
        
        <channel id="echo"/>
        
        <stream:stdout-channel-adapter channel="echo"/>
        I get the following error:
        Code:
        Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No poller has been defined for channel-adapter 'org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean#0', and no default poller is available within the context.
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
        	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
        	at com.gameware.platform.gameclient.runtime.Bootstrap.main(Bootstrap.java:10)
        Caused by: java.lang.IllegalArgumentException: No poller has been defined for channel-adapter 'org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean#0', and no default poller is available within the context.
        	at org.springframework.util.Assert.notNull(Assert.java:112)
        	at org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean.initializeAdapter(SourcePollingChannelAdapterFactoryBean.java:125)
        	at org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean.afterPropertiesSet(SourcePollingChannelAdapterFactoryBean.java:95)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
        	... 12 more
        I guess the problem is:
        No poller has been defined for channel-adapter 'org.springframework.integration.config.SourcePoll ingChannelAdapterFactoryBean#0', and no default poller is available within the context.

        But I havn't defined any channel-adapter named "SourcePollingChannelAdapterFactoryBean"

        Comment


        • #5
          The name SourcePollingChannelAdapterFactoryBean is auto generated for your channel adapter stdin-channel-adapter. You can either define a poller as a child element of the stdin-channel-adapter or define a global default poller. Link below is the section of the reference manual showing examples.

          http://static.springsource.org/sprin...hannel-adapter

          Comment


          • #6
            Hello
            SourcePollingChannelAdapterFactoryBean
            it is backing class for
            <stream:stdin-channel-adapter channel="echo"/>
            I see you are novice in SI. So, please, following down instructions as is. And read the manual for deeper knowledge.
            In your case you must declare this:
            <poller default="true" fixed-rate="50"/>
            It is necessary for pooling the stdin
            Good luck,
            Artem

            Comment

            Working...
            X