logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Caroline Wood <Caroline.W...@cpp.co.uk>
Subject FW: Serialization problem?
Date Mon, 11 Jul 2005 08:37:32 GMT

Any ideas? Thanks. :-)

 

Hi folks,

 

Can anyone work out what I'm doing wrong?

I've written an appender that extends JMS appender, and also a MDB to
process the messages.

The logging message is a simple data container class called MonitorMessage.

 

However, the data object does not seem to be (de)serializing properly and is
arriving in the MDB as a String. The Data class does implement serializable!

 

The junit test looks like this:

---

public void testSimpleMonAppender() {

    MonitorMessage msg = new MonitorMessage( new Integer( 1 ) );

    LOG.info( msg );

  }

---

The relevant code in the MDB is:

---

public void onMessage( Message msg ) {

    LOGGER.debug( "Got a monitoring message!" );

 

    ObjectMessage om;

    LoggingEvent event;

    MonitorMessage message;

    if( msg instanceof ObjectMessage ) {

      om = (ObjectMessage)msg;

      try {

        // Get the logging event from the message

        event = (LoggingEvent)om.getObject();

 

        // Check the message type

        LOGGER.debug("The message is an instance of " +
event.getMessage().getClass());

        LOGGER.debug("At level " + event.getLevel().toString());

        if(event.getMessage() instanceof MonitorMessage) {

          message = (MonitorMessage)event.getMessage();

          LOGGER.debug("The id is " + message.getMessageIdentifier());

        }

        else if(event.getMessage() instanceof java.lang.String) {

          LOGGER.debug("The string is " + event.getMessage());

        }

        else {

          LOGGER.debug(event.getMessage().toString());

        }

      }

      catch( javax.jms.JMSException ex ) {

        LOGGER.error( "JMS exception when getting the logging event : ", ex
);

      }

 

    }

    else {

      try {

        LOGGER.warn( "Warning - the message type is " + msg.getJMSType() +
", the expected type was ObjectMessage" );

      }

      catch( javax.jms.JMSException ex ) {

        LOGGER.error( "JMS exception when getting the JMS message type: ",
ex );

      }

    }

 

    LOGGER.debug( "Processed monitoring message!" );

  }

}

---

The debug from the MDB looks like this:

---

) - Processed monitoring message!

2005-07-06 11:34:57,268 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:65)

 - Got a monitoring message!

2005-07-06 11:34:57,270 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:77)

 - The message is an instance of class java.lang.String

2005-07-06 11:34:57,271 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:78)

 - At level INFO

2005-07-06 11:34:57,271 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:84)

 - The string is [ messageIdentifier = 1

2005-07-06 11:34:57,272 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:104

) - Processed monitoring message!

---

What am I doing wrong?!

Tia,

Caroline.




This is an email from the CPP Group Plc, Holgate Park, York, YO26 4GA; telephone 01904 544500.
This message may contain information that is confidential. If you are not the intended recipient,
you may not peruse, use, disseminate, distribute or copy this message. If you have received
this
message in error, please notify the sender immediately by email, facsimile or telephone and
either
return or destroy the original message.
The CPP Group Plc accepts no responsibility for any changes made to this message after it
has been
sent by the original author.  This email has been scanned for all viruses by the MessageLabs
Email Security System.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message