Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: spring integration spring-integration-2.1.0.RC1

  1. #1
    Join Date
    Dec 2011
    Posts
    15

    Default spring integration spring-integration-2.1.0.RC1

    Hello,

    1. Kindly let me know about a good link explains about channels, service activators, inbound - outbound with sample configurations.

    2. While trying sample code for spring integration gives an error of "no such method" - looks like some jar is missing - not suire which one. Added all jars which comes with download of spring integration spring-integration-2.1.0.RC1.

    code is below

    public class HelloWorldApp {

    private static Logger logger = Logger.getLogger(HelloWorldApp.class);

    public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext(
    "dd/helloworlddemo.xml");
    MessageChannel inputChannel = (MessageChannel) context.getBean(
    "inputChannel", MessageChannel.class);
    PollableChannel outputChannel = (PollableChannel) context.getBean(
    "outputChannel", PollableChannel.class);
    inputChannel.send(new GenericMessage<String>("World"));
    logger.info("==> HelloWorldDemo: "
    + outputChannel.receive(0).getPayload());
    }

    }

    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/integration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd">


    <channel id="inputChannel"/>

    <channel id="outputChannel">
    <queue capacity="10"/>
    </channel>

    <service-activator input-channel="inputChannel"
    output-channel="outputChannel"
    ref="helloService"
    method="sayHello"/>

    <beans:bean id="helloService" class="com.hcl.sprngintg.HelloService"/>

    </beans:beans>


    3. Any example which has inbound as file with polling and outbound as JMS message or webservice message will be great.


    Thanks

  2. #2
    Join Date
    Dec 2011
    Posts
    15

    Default error (no such method) with spring integration 2.1.0.rc1

    Kindly help we are facing same issue - while running spring integration sample - ver 2.1.0.rc1

    (1)
    Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.beans.factory.support.RootBean Definition.<init>(Ljava/lang/StringV
    at org.springframework.integration.config.xml.Default ConfiguringBeanFactoryPostProcessor.registerIdGene ratorConfigurer(DefaultConfiguringBeanFactoryPostP rocessor.java:86)
    at org.springframework.integration.config.xml.Default ConfiguringBeanFactoryPostProcessor.postProcessBea nFactory


    (2)
    import org.springframework.context.support.AbstractApplic ationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;
    import org.springframework.integration.MessageChannel;
    import org.springframework.integration.message.GenericMes sage;


    public class Simple {
    public static void main(String[] args) {
    AbstractApplicationContext context = null;

    context = new ClassPathXmlApplicationContext("dd/simple.xml");


    MessageChannel inChannel = (MessageChannel) context.getBean("numberChannel");
    inChannel.send(new GenericMessage<String>("5"));


    }
    }




    (3)

    <?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/integration
    http://www.springframework.org/schem...ntegration.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">


    <int:channel id="stringOrNumberChannel" datatype="java.lang.String,java.lang.Number" />

    </beans>



    (4) how does service activator work?? What is the difference between gateway and adapter???


    thanks

  3. #3
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    1. The reference manual is an excellent source of information you'll need

    2. The github link for the samples has numerous samples which can help you understand things better.

    3. Regarding the exception, what version of spring are you using?

    4. While posting, post all you code between the [ CODE ] [/ CODE ] (without the spaces) tags

  4. #4
    Join Date
    Dec 2011
    Posts
    15

    Default

    Amol,

    Answer to your point (3)
    3. Regarding the exception, what version of spring are you using?
    Jars used ->
    spring-integration-core-2.1.0.RC1.jar
    spring-integration-file-2.1.0.RC1.jar
    commons-logging-1.0.4.jar
    spring.jar - ver 3.x

    Kindly let me know correct combination/versions of jars to be used.


    Query -> How does integration between inbound and outbound channel happen? Is it using service activator? Apologies if my question is basic. My doubt we specify different channels for inbound / outbound but still message flow.

    Thanks

  5. #5
    Join Date
    Dec 2011
    Posts
    15

    Default

    Amol please find stubs giving exception (nosuchmethod) with above jars
    Please try from your side and let us know.

    --------------------------------------------------
    <code>
    import org.springframework.context.support.AbstractApplic ationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;
    import org.springframework.integration.MessageChannel;
    import org.springframework.integration.message.GenericMes sage;
    public class Simple {
    public static void main(String[] args) {
    AbstractApplicationContext context = null;
    context = new ClassPathXmlApplicationContext("dd/simple.xml");
    MessageChannel inChannel = (MessageChannel) context.getBean("stringOrNumberChannel");
    inChannel.send(new GenericMessage<String>("5"));

    }
    }
    </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/integration
    http://www.springframework.org/schem...ntegration.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">
    <int:channel id="stringOrNumberChannel" datatype="java.lang.String,java.lang.Number" />
    </beans>
    --------------------------------------------------

    Thanks

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Looking at your exception I am not sure that your are using Spring 3.x. In fact the exception tells me that you are using Spring 2.5.x since version 3.0 of RootBeanDefinition definitely has a constructor that takes String. So you might be using the wrong version of Spring or you may have two versions on the classpath

  7. #7
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Also to add to what oleg said, since spring 3.x we no longer have the bit fat jar containing all the classes (unless you have built one yourself). So which spring.jar are you using?
    You will find this class in spring-beans-{VERSION}.RELEASE.jar

  8. #8
    Join Date
    Dec 2011
    Posts
    15

    Default

    Thanks Oleg / Amol. As Oleg suggested earlier problem was with wrong version of jar. Examples are running fine. Great framework like openadapter.

    My query serviceactivator - is to couple inbound and outbound channel???

    Myself tried inbound adapter as file adapter and outbound adapter as jms. Basically want to to test read from file and send to queue. But is not happening as expected. Handler class is not getting invoked. If I hook a listener to listen to the queue it is not getting messages.


    configuration-->

    common.xml
    <?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:integration="http://www.springframework.org/schema/integration"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd">

    <bean id="connectionFactory"
    class="org.springframework.jms.connection.CachingC onnectionFactory">
    <property name="targetConnectionFactory">
    <bean class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="tcp://localhost:61616" />
    </bean>
    </property>
    <property name="sessionCacheSize" value="10" />
    <property name="cacheProducers" value="false" />
    </bean>

    <bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="queue.request" />
    </bean>

    <bean id="replyQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="queue.response" />
    </bean>

    <integrationoller id="poller" default="true"
    fixed-delay="1000" />
    </beans>

    ------------------------------------------------------
    <?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:integration="http://www.springframework.org/schema/integration"
    xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:jms="http://www.springframework.org/schema/integration/jms"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schem...ntegration.xsd
    http://www.springframework.org/schema/integration/file
    http://www.springframework.org/schem...ation-file.xsd
    http://www.springframework.org/schema/integration/jms
    http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
    <bean
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer" />

    <file:inbound-channel-adapter id="filesIn"
    directory="e:\\software\\complete\\"
    filename-pattern="[a-z]+.txt">
    <integrationoller id="poller" fixed-delay="500" />
    </file:inbound-channel-adapter>
    <file:file-to-string-transformer
    input-channel="filesIn" output-channel="strings" />

    <integration:channel id="strings" />
    <integration:channel id="strgToJmsoutChannel" />
    <integration:service-activator input-channel="strings" output-channel="strgToJmsoutChannel" ref="handler" method="handleString" />
    <jms:outbound-channel-adapter id="jmsout" channel="strgToJmsoutChannel" destination="requestQueue" />

    <bean id="handler"
    class="Handler" />
    </beans>


    ----------------------------------------------

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;

    public class TextFileCopyTest {

    private final static String[] configFiles = { "dd/common.xml",
    "dd/fileCopyDemo-text.xml" };

    public void testTextBasedCopy() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(
    configFiles, TextFileCopyTest.class);
    //FileCopyDemoCommon.displayDirectories(context);
    Thread.sleep(5000);
    }

    public static void main(String[] args) throws Exception {
    TextFileCopyTest test = new TextFileCopyTest();
    test.testTextBasedCopy();
    }

    }
    -------------------------------------------------------------------
    import java.io.File;

    public class Handler {

    public String handleString(String input) {
    System.out.println("***************** Copying text: ************" + input);
    return input.toUpperCase();
    }

    public File handleFile(File input) {
    System.out.println("Copying file: " + input.getAbsolutePath());
    return input;
    }

    public byte[] handleBytes(byte[] input) {
    System.out.println("Copying " + input.length + " bytes ...");
    return new String(input).toUpperCase().getBytes();
    }

    }
    ----------------------------------------------------

  9. #9
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Use filename-regex instead of filename-pattern. If you want to use filename-pattern, use the value as *.txt

    Also, please format you code well to improve the readability of the post.
    Last edited by Amol Nayak; Dec 23rd, 2011 at 11:55 AM. Reason: suggested the formatting of the post before posting

  10. #10
    Join Date
    Dec 2011
    Posts
    15

    Default

    Thanks Amol -will try with -> "*.txt" but existing exp should also work?
    Requirement is channel inbound adapter should read text file -> convert content into string -> send to jms outbound adapter (activemq)

    Listener on a different machine should be able to receive this message.

Posting Permissions

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