2 Replies Latest reply on Nov 26, 2011 6:30 AM by Tomasz Ostrowski

    jms bc seems do not receive a message - simple case

    Tomasz Ostrowski Newbie

      Hello, I was training with setting up a simple ESB based application (example from a book) and I stucked with a problem. The application should work like this:

      1) a junit test connects to the broker and sends a simple message

      2) jms bc receives that message and push it to the bean se

      3) bean se outputs on the screen information that it received the message (I guess I should see it in servicemix.log)


      But there is some problem. As I run the JUnit I see that the message is send to the localhost:61616, but I have no idea why jms does not collect it..

      My code below:


      On ESB side I have to components: jms bc & bean se


      xbean for jms bc:


      <?xml version="1.0" encoding="UTF-8"?>

      <beans xmlns="http://www.springframework.org/schema/beans"





             <amqpool:pool id="connectionFactory" url="tcp://localhost:61616" maxConnections="8" />


             <jms:consumer service="esb:simpleConsumer"









      xbean for bean se:


      <?xml version="1.0" encoding="UTF-8"?>

      <beans xmlns="http://www.springframework.org/schema/beans"




        <bean:endpoint service="esb:beanLoggingService"

      +           endpoint="loggingEndpoint"+

      +           bean="#SimLogBean"/>+


        <bean id="SimLogBean" class="esb.toos.logging.SimpleLoggingBean"/>





      SimpleLoggingBean class:


      package esb.toos.logging;


      import org.apache.log4j.Logger;

      import org.apache.servicemix.MessageExchangeListener;

      import org.apache.servicemix.components.util.ComponentSupport;

      import org.apache.servicemix.jbi.jaxp.SourceTransformer;


      import javax.annotation.Resource;

      import javax.jbi.messaging.*;

      import javax.xml.transform.TransformerException;


      public class SimpleLoggingBean extends ComponentSupport implements MessageExchangeListener {

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

          private SourceTransformer sourceTransformer = new SourceTransformer();



          private DeliveryChannel channel;


          public void onMessageExchange(MessageExchange messageExchange) throws MessagingException {

              NormalizedMessage message = getInMessage(messageExchange);

              try {

                 +LOGGER.info("Received payload: " + sourceTransformer.toString(message.getContent()));+

              } catch(TransformerException e) {

                 LOGGER.error("Error while reading payload ", e);









      Outside ESB there is a simple JUnit test


      Junit Test:


      package com.toos.test;


      import org.apache.activemq.ActiveMQConnection;

      import org.junit.Test;


      import javax.jms.Destination;

      import javax.jms.MessageProducer;

      import javax.jms.Session;

      import javax.jms.TextMessage;


      public class TestSolution {



           public void helloComponent() throws Exception {


                ActiveMQConnection connection = ActiveMQConnection.makeConnection("tcp://localhost:61616");



               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

               Destination destination = session.createQueue("simple.input");

                TextMessage simpleMessage = session.createTextMessage();


                MessageProducer producer = session.createProducer(destination);










      I just have no more ideas how to fix it. Any help would be very welcome.

      If you need any more information I will provide it to you asap





      Edited by: czystaf on Nov 24, 2011 8:14 PM