Announcement Announcement Module
Collapse
No announcement yet.
Looking for spring jms channel example Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for spring jms channel example

    Hi all,

    I've just started to have a look into Spring integration framework and I'm looking for a simple working spring jms channel example.
    Simple use case: a queue registered into Weblogic and a spring jms channel for listening to that queue and echo consumed messages into stdout.

    Below my applicationContext.xml but I'm not sure if it is the right one :-)
    Could you please help me in order to remove/add what is wrong/is missing about my applicationContext.xml ?

    Thanks in advance and regards
    nuvola

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/integration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jms="http://www.springframework.org/schema/integration/jms"
    xmlns:stream="http://www.springframework.org/schema/integration/stream"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xmlns:jee="http://www.springframework.org/schema/jee"
    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/schem...ntegration.xsd
    http://www.springframework.org/schema/integration/jms
    http://www.springframework.org/schem...ration-jms.xsd
    http://www.springframework.org/schem...gration/stream
    http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">

    <context:component-scan base-package="dev.spring.integration.jms"/>

    <!-- Gateway is the place where process initiates -->
    <jms:inbound-gateway id="jmsInboundGateway"
    request-destination="myQueue"
    request-channel="myListenerChannel"/>

    <int:channel id="myListenerChannel"/>

    <service-activator input-channel="myListenerChannel" ref="myListenerBean"/>

    <!--A default JMS message listener -->
    <int-jms:message-driven-channel-adapter id="jmsMessageAdapter"
    destination="myQueue"
    channel="myListenerJMSInChannel" />

    <int:channel id="myListenerJMSInChannel" />

    <stream:stdout-channel-adapter id="stdout" channel="myListenerJMSInChannel" append-newline="true"/>

    <jee:jndi-lookup id="connectionFactory" jndi-name="jms/connectionFactory">
    <jee:environment>
    java.naming.factory.initial=weblogic.jndi.WLInitia lContextFactory
    java.naming.provider.url=t3://localhost:7001
    </jee:environment>
    </jee:jndi-lookup>
    <jee:jndi-lookup id="myQueue" jndi-name="WL.jms.Queue">
    <jee:environment>
    java.naming.factory.initial=weblogic.jndi.WLInitia lContextFactory
    java.naming.provider.url=t3://localhost:7001
    </jee:environment>
    </jee:jndi-lookup>

    </beans>

  • #2
    If your use case is one-way as you've described (e.g. JMS->stdout), then you don't need that inbound-gateway, just keep the message-driven-channel-adapter.

    BTW, please use [ CODE ] (without the space) tags around your code/config excerpts in the future (easier to read).

    -Mark

    Comment


    • #3
      Hi Mark,

      thanks a lot for your feedback.
      I removed the inbound-gateway and just keep the message-driven-channel-adapter.

      Now running the test I got below exception: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

      and I'm looking for what I need to add to my pom.xml.

      As anyone has any hint about that ?

      Thanks and regards
      nuvola


      Code:
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jms.listener.DefaultMessageListenerContainer#0': Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory': Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]

      Comment


      • #4
        Hi all,

        issue "java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory" solved :-)

        Below for info, anyone can find steps I did for who is interested on that.

        Run "java -jar wljarbuilder.jar -profile weblogic-maven-plugin"
        A weblogic-maven-plugin.jar is created under WLSERVER\server\lib folder.

        Finally to install under Maven repository:
        mvn install:install-file -Dfile=<path where is your file>\weblogic-maven-plugin.jar -DpomFile=pom.xml

        Thanks and regards
        nuvola

        Comment

        Working...
        X