You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by to...@privat.dk on 2002/07/23 17:28:41 UTC

JMS and MDB

Hi,

I have a problem regarding JMSAppender

I have a client program issuing a 


           log.debug(logBean)

where logBean is a instance of my own class LogBean (it's Serializable).
I'm using a MDB to receive this log message.

I'm able to get the LoggingEvent in the MDB, by

           LoggingEvent event = (LoggingEvent)omessage.getObject();

but I can't get my instance of type LogBean by

           LogBean bean = (LogBean)event.getMessage().

I get a ClassCastException, and I can se that it states, that it's a String object and not a LogBean object.

I can se in JMSAppender in the append() method, that the object send is in fact a LogBean instance, but as mentioned when received in MDB, it states it's a String.

Why is that ?

br
   Torben Bruun



_______________________________________________________
Denne mail er sendt via Mail på Opasia.
Få en gratis freemail mailboks på http://mail.opasia.dk

Følg med i de danske nyhedsgrupper på 
http://nyhedsgrupper.opasia.dk
_______________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JMS and MDB

Posted by to...@privat.dk.
Hi,

Well my hope/idea was that I could log any kind of Object (that was serializable) and then I could deside at JMS receiver side what to do with the logged object. Write it to DB or something else determined by the object/class type.
But this doesn't seem to be possible. It looks like it would have to extend the LoggingEvent class or put all information into the message (String) and then take it out again on the receiving side. The first solution seemed somewhat more beautiful to me.

br
    Torben

Ceki Gülcü <ce...@qos.ch> wrote:
> 
> The reason for this exception is because log4j transforms
> the message
> object into String before serialization, i.e. transmission
> on the
> wire. This precautionary step avoids the serialization of
> potentially
> very large message objects. Moreover, the advantage of
> serializing
> message objects remains unclear. Can you please explain why
> you want
> to serialize the LogBean object and the advantages that
> would bring?
> 
> At 17:28 23.07.2002 +0200, torben.bruun@privat.dk wrote:
> >Hi,
> >
> >I have a problem regarding JMSAppender
> >
> >I have a client program issuing a
> >
> >
> >            log.debug(logBean)
> >
> >where logBean is a instance of my own class LogBean (it's
> Serializable).
> >I'm using a MDB to receive this log message.
> >
> >I'm able to get the LoggingEvent in the MDB, by
> >
> >            LoggingEvent event =
> (LoggingEvent)omessage.getObject();
> >
> >but I can't get my instance of type LogBean by
> >
> >            LogBean bean = (LogBean)event.getMessage().
> >
> >I get a ClassCastException, and I can se that it states,
> that it's a 
> >String object and not a LogBean object.
> >
> >I can se in JMSAppender in the append() method, that the
> object send is in 
> >fact a LogBean instance, but as mentioned when received in
> MDB, it states 
> >it's a String.
> >
> >Why is that ?
> >
> >br
> >    Torben Bruun
> 
> --
> Ceki
> 
> For complete log4j documentation, please see
> http://qos.ch/log4jBook.html
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


_______________________________________________________
Denne mail er sendt via Mail på Opasia.
Få en gratis freemail mailboks på http://mail.opasia.dk

Følg med i de danske nyhedsgrupper på 
http://nyhedsgrupper.opasia.dk
_______________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JMS and MDB

Posted by Ceki Gülcü <ce...@qos.ch>.
The reason for this exception is because log4j transforms the message
object into String before serialization, i.e. transmission on the
wire. This precautionary step avoids the serialization of potentially
very large message objects. Moreover, the advantage of serializing
message objects remains unclear. Can you please explain why you want
to serialize the LogBean object and the advantages that would bring?

At 17:28 23.07.2002 +0200, torben.bruun@privat.dk wrote:
>Hi,
>
>I have a problem regarding JMSAppender
>
>I have a client program issuing a
>
>
>            log.debug(logBean)
>
>where logBean is a instance of my own class LogBean (it's Serializable).
>I'm using a MDB to receive this log message.
>
>I'm able to get the LoggingEvent in the MDB, by
>
>            LoggingEvent event = (LoggingEvent)omessage.getObject();
>
>but I can't get my instance of type LogBean by
>
>            LogBean bean = (LogBean)event.getMessage().
>
>I get a ClassCastException, and I can se that it states, that it's a 
>String object and not a LogBean object.
>
>I can se in JMSAppender in the append() method, that the object send is in 
>fact a LogBean instance, but as mentioned when received in MDB, it states 
>it's a String.
>
>Why is that ?
>
>br
>    Torben Bruun

--
Ceki

For complete log4j documentation, please see http://qos.ch/log4jBook.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>