Announcement Announcement Module
Collapse
No announcement yet.
Using JmsMessageDrivenSourceAdapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using JmsMessageDrivenSourceAdapter

    I have been trying to use the JmsMessageDrivenSourceAdapter. By my understanding of the documentation, it should create a container listener over a queue and allow for multiple receivers to be passed the messages as they arrive. I have gotten this to work using Spring's standard SimpleMessageListenerContainer and MessageListenerAdapter and see the connection created to the queue manager. Although there are no critical errors when it is run, there are no connections to the queue manager. I have tried it with both WMQ Series and Active MQ with the same results. Here is the code.

    Configuration
    <message-bus dispatcher-pool-size="25" auto-create-channels="true" >
    <annotation-driven />
    <context:component-scan base-package="com.springinttest" />

    <channel id="inputChannel1" />

    <endpoint input-channel="inputChannel1" handler-ref="MyMdp"
    handler-method="processMessage">
    <concurrency core="5" max="25" />
    </endpoint>

    <beans:bean id="MySourceAdapter"
    class="org.springframework.integration.adapter.jms .JmsMessageDrivenSourceAdapter"
    lazy-init="false" init-method="initialize">
    <beansroperty name="connectionFactory"
    ref="connectionFactory" />
    <beansroperty name="destination" ref="destination" />
    <beansroperty name="channel" ref="inputChannel1" />
    </beans:bean>

    <beans:bean id="connectionFactory"
    class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <beansroperty name="brokerURL" value="tcp://localhost:61616" />
    </beans:bean>

    <beans:bean id="destination"
    class="org.apache.activemq.command.ActiveMQQueue">
    <beans:constructor-arg index="0" value="myQueue"/>
    </beans:bean>


    <beans:bean id="MyMdp" class="com.springinttest.MyMdp" />

    </beans:beans>

    Handler

    package com.springinttest;

    import org.springframework.integration.annotation.Message Endpoint;
    import org.springframework.integration.annotation.Handler ;
    import org.apache.log4j.Logger;

    @MessageEndpoint(input="inputChannel1")
    public class MyMdp {

    private static final Logger LOGGER = Logger.getLogger(MyMdp.class);

    public MyMdp() {
    LOGGER.warn("Constructor Set");
    }
    @Handler
    public void processMessage(String message) {

    try {
    System.out.println(message.toString());
    LOGGER.warn("Received message is: " + message.toString());
    } catch (Exception e) {
    System.out.println("Captain Chaos");
    // handle this-somehow
    }
    }
    }

  • #2
    More information

    I found the issue, but this is still strange. I was building my project using Maven and deploying on Tomcat. The Maven Repositories that we use here, S3Browse.com, for example only had the core jar file listed and only for m1. So I did not realize I was missing the adapters jar until yesterday. The funny thing is Spring loaded everything and did not complain that it could not find the JmsMessageDrivenSourceAdapter class. It just ran and issued no errors, which is what through me off. Does anyone know of a good Maven repository that has both jars for m2 that I should be using? Thanks

    Comment


    • #3
      Thanks for pointing that out. I will look into the milestone repository and make sure that the M2 jars are available.

      Actually, the snapshot repository is up to date: http://s3browse.com/explore/maven.sp...k/integration/

      The jars with a "ci" suffix are produced from our continuous integration build each night. For example, the "ci-57" jars correspond to nightly build 57: https://build.springframework.org/browse/INT-NIGHTLY-57

      There you can even see what issues are included in each build, and links to Jira are provided as well.

      -Mark

      Comment


      • #4
        The M2 jars are now available in the milestone repository as well: http://s3browse.com/explore/maven.sp...k/integration/

        -Mark

        Comment

        Working...
        X