2 Replies Latest reply on Feb 16, 2011 5:31 PM by Bruno Santos

    how to use JMSAppender and HornetQ?

    Bruno Santos Newbie

      Hi all!

       

      I've recently downloaded JBoss AS 6 andI would appreciate some help figuring the usage and integration of JMSAppender with HornetQ. The problem is that I'm not being able to get any messages on the MDB.

       

      For simplicity I've turned off security on in HornetQ. I'm also able to see the topic and and the deployed MDB in the jmx-console.

       

      Having said this, here is my configuration diff when compared with the default one:

       

      jboss-logging.xml

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

      ...

         <log4j-appender name="JMS" autoflush="true" class="org.apache.log4j.net.JMSAppender">

            <error-manager>

               <only-once/>

            </error-manager>

       

            <level name="INFO"/>

       

            <properties>

               <property name="topicConnectionFactoryBindingName">java:/ConnectionFactory

                  <!-- Use injection so that an implicit dependency is formed - TODO: get the correct property name -->

                  <!-- b:inject bean="myTopicBiding" property="NettyConnectionFactory"/ -->

               </property>

               <property name="topicBindingName">topic/LogTopic"</property>

            </properties>

         </log4j-appender>

       

      ...

       

         <root-logger>

            <!-- Set the root logger priority via a system property, with a default value. -->

            <level name="${jboss.server.log.threshold:INFO}"/>

            <handlers>

               <handler-ref name="CONSOLE"/>

               <handler-ref name="FILE"/>

               <handler-ref name="JMS"/>

            </handlers>

         </root-logger>

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

       

      hornetq-jms.xml

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

      ...

         <topic name="LogTopic">

                               <entry name="topic/LogTopic"/>

         </topic>

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

       

      hornetq-configuration.xml

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

      ...

      <security-enabled>false</security-enabled>

      ...

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

       

      MDB

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

      import javax.ejb.ActivationConfigProperty;

      import javax.ejb.MessageDriven;

      import javax.jms.Message;

      import javax.jms.MessageListener;

      import javax.jms.ObjectMessage;

       

       

      import org.apache.log4j.spi.LoggingEvent;

       

       

      @MessageDriven(activationConfig = {

              @ActivationConfigProperty(propertyName = "destinationType",

                      propertyValue = "javax.jms.Topic"),

              @ActivationConfigProperty(propertyName = "destination",

                      propertyValue = "topic/LogTopic"),

              @ActivationConfigProperty(propertyName = "maxSession",

                                     propertyValue = "1"),

              @ActivationConfigProperty(propertyName="user",

                                  propertyValue="guest"),

              @ActivationConfigProperty(propertyName="password",

                                  propertyValue="guest")})

      public class LogTopicMessageBean implements MessageListener {

       

          public void onMessage(final Message message) {

                    LoggingEvent event;

              try {

                   if (message instanceof ObjectMessage) {

                        ObjectMessage objectMessage = (ObjectMessage) message;

                        event = (LoggingEvent) objectMessage.getObject();

                        System.err.println(event.getRenderedMessage());

                        System.out.println(event.getRenderedMessage());

                   }

              } catch (Throwable t) {

                        t.printStackTrace();

              }

          }

       

      }

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

       

       

      Any help would be appreciated, thanks!