2 Replies Latest reply on Aug 28, 2002 11:08 AM by Mauro Ramon

    Problem with Log4j and JMSAppender

    Mauro Ramon Newbie

      hi all, we got a problem when trying to use Log4J with JMSAppender. We are using Jboss 3.0+Jetty.
      We defined a Topic in jbossmq-destinations-service.xml
      <mbean code="org.jboss.mq.server.jmx.Topic"name="jboss.mq.destination:service=Topic,name=topicLogTest">
      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager

      We configured Log4J of the following form:
      log4j.category.com.sancorseguros.nova =INFO, JMS


      Everything seem to work fine for logging. We have create an stand-alone class to subscribe to topic. A fragment of code:
      try {
      InitialContext ctx = new InitialContext();
      TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
      topicCon = tcf.createTopicConnection();
      TopicSession topicSess = topicCon.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
      Topic topic = (Topic) ctx.lookup("topic/topicLogTest");
      TopicSubscriber topicSubscriber = topicSess.createSubscriber(topic);
      TextListener listener = new TextListener();
      while (this.start) {
      / /nada
      } catch(Exception e) {
      } finally {
      if (topicCon != null) {
      try {
      } catch(Exception e) {

      TextListener to implement MessageListener.
      public void onMessage(Message message) {
      TextMessage msg = null;
      try {
      if (message instanceof TextMessage) {
      msg = (TextMessage) message;
      System.out.println("Reading message: " +msg.getText());
      } else {
      System.out.println("Message of wrong type: " + message.getClass().getName());
      } catch (JMSException e) {
      System.out.println("JMSException in onMessage(): " +e.toString());
      } catch (Throwable t) {
      System.out.println("Exception in onMessage():" + t.getMessage());

      The problem occur when TextListener try to evaluate message instanceof TextMessage. The class type for Message parameter is org.jboss.mq.SpyObjectMessage and we don't to see the text message.

      We have forgot to configure something???
      Please, any tip are welcome.
      Thanks in advance.
      PD:Sorry for my english please