Ah, that makes sense now, thanks. Would the best strategy for passing an object via the message be to override the toString() method to marshal the object to an xml string? Or is there a better way of approaching this?
Many thanks, Caroline. -----Original Message----- From: Tom Drake [mailto:[EMAIL PROTECTED] Sent: 11 July 2005 19:24 To: 'Log4J Users List' Subject: RE: Serialization problem? This is the defined behaviour. You may configure an ObjectRenderer to gain finer control over how your message is converted into a string, but Log4j will turn this message into string form prior to sending across a socket, or to a JMS queue. -----Original Message----- From: Caroline Wood [mailto:[EMAIL PROTECTED] Sent: Monday, July 11, 2005 1:38 AM To: 'log4j-user@logging.apache.org' Subject: FW: Serialization problem? 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]