On Fri, Nov 7, 2008 at 8:54 PM, Andreas Veithen
<[EMAIL PROTECTED]>wrote:

> I think that the absolute values of the bytesSent and bytesReceived
> metrics are actually not so important. What is more important is the
> ability to monitor their evolution over time to identify trends or
> peaks. E.g. if you have a system where you observe a steady increase
> of volume, you might want to extrapolate and carry out some load
> testing to make sure that it will support the expected future
> workload.


+1, it makes sense.

>
>
> I put the review comment in the code to give people a chance to think
> about it and maybe come up with some ideas. Personally I think that
> for TextMessages, we should simply make the assumption that 1
> character = 1 byte. In many cases, that will underestimate the message
> size, but it still provides sufficiently accurate information without
> causing overhead.


Well I'm not quite satisfied with this. Can you exactly say that 1 character
= 1 byte, or shouldn't this be some weighted value?  This is my point: how
could you compare the load of BytesMessages vs TextMessages using this
scheme? or doesn't such a comparison make sense?

Regards,
Senaka

>
>
> Andreas
>
> On Fri, Nov 7, 2008 at 15:40, Senaka Fernando <[EMAIL PROTECTED]> wrote:
> > Hi Andreas,
> >
> > I had another question asked on this on the list. That is, "how can you
> > express the size of a message exchanged, just by counting the bytes that
> are
> > required to represent the payload?". I believe that this is only a rough
> > estimate.
> >
> > Regards,
> > Senaka
> >
> > On Fri, Nov 7, 2008 at 8:06 PM, <[EMAIL PROTECTED]> wrote:
> >
> >> Author: veithen
> >> Date: Fri Nov  7 06:36:19 2008
> >> New Revision: 712137
> >>
> >> URL: http://svn.apache.org/viewvc?rev=712137&view=rev
> >> Log:
> >> JMS transport: eliminated some duplicate code and added a review
> comment.
> >>
> >> Modified:
> >>
> >>
>  
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
> >>
> >>
>  
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
> >>
> >>
>  
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
> >>
> >> Modified:
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java?rev=712137&r1=712136&r2=712137&view=diff
> >>
> >>
> ==============================================================================
> >> ---
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
> >> (original)
> >> +++
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
> >> Fri Nov  7 06:36:19 2008
> >> @@ -101,13 +101,7 @@
> >>
> >>         // update transport level metrics
> >>         try {
> >> -            if (message instanceof BytesMessage) {
> >> -
> >>  metrics.incrementBytesReceived((JMSUtils.getBodyLength((BytesMessage)
> >> message)));
> >> -            } else if (message instanceof TextMessage) {
> >> -                metrics.incrementBytesReceived(((TextMessage)
> >> message).getText().getBytes().length);
> >> -            } else {
> >> -                handleException("Unsupported JMS message type : " +
> >> message.getClass().getName());
> >> -            }
> >> +
> >>  metrics.incrementBytesReceived(JMSUtils.getMessageSize(message));
> >>         } catch (JMSException e) {
> >>             log.warn("Error reading JMS message size to update transport
> >> metrics", e);
> >>         }
> >>
> >> Modified:
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java?rev=712137&r1=712136&r2=712137&view=diff
> >>
> >>
> ==============================================================================
> >> ---
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
> >> (original)
> >> +++
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
> >> Fri Nov  7 06:36:19 2008
> >> @@ -241,15 +241,7 @@
> >>
> >>                     metrics.incrementMessagesSent();
> >>                     try {
> >> -                        if (message instanceof BytesMessage) {
> >> -
> >>  metrics.incrementBytesSent(JMSUtils.getBodyLength((BytesMessage)
> message));
> >> -                        } else if (message instanceof TextMessage) {
> >> -                            metrics.incrementBytesSent((
> >> -                                (TextMessage)
> >> message).getText().getBytes().length);
> >> -                        } else {
> >> -                            handleException("Unsupported JMS message
> type
> >> : " +
> >> -                                message.getClass().getName());
> >> -                        }
> >> +
> >>  metrics.incrementBytesSent(JMSUtils.getMessageSize(message));
> >>                     } catch (JMSException e) {
> >>                         log.warn("Error reading JMS message size to
> update
> >> transport metrics", e);
> >>                     }
> >> @@ -335,15 +327,7 @@
> >>                 // update transport level metrics
> >>                 metrics.incrementMessagesReceived();
> >>                 try {
> >> -                    if (reply instanceof BytesMessage) {
> >> -
> >>  metrics.incrementBytesReceived(JMSUtils.getBodyLength((BytesMessage)
> >> reply));
> >> -                    } else if (reply instanceof TextMessage) {
> >> -                        metrics.incrementBytesReceived((
> >> -                            (TextMessage)
> >> reply).getText().getBytes().length);
> >> -                    } else {
> >> -                        handleException("Unsupported JMS message type :
> "
> >> +
> >> -                            reply.getClass().getName());
> >> -                    }
> >> +
> >>  metrics.incrementBytesReceived(JMSUtils.getMessageSize(reply));
> >>                 } catch (JMSException e) {
> >>                     log.warn("Error reading JMS message size to update
> >> transport metrics", e);
> >>                 }
> >>
> >> Modified:
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
> >> URL:
> >>
> http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java?rev=712137&r1=712136&r2=712137&view=diff
> >>
> >>
> ==============================================================================
> >> ---
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
> >> (original)
> >> +++
> >>
> webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSUtils.java
> >> Fri Nov  7 06:36:19 2008
> >> @@ -745,6 +745,20 @@
> >>         return length;
> >>     }
> >>
> >> +    public static long getMessageSize(Message message) throws
> JMSException
> >> {
> >> +        if (message instanceof BytesMessage) {
> >> +            return JMSUtils.getBodyLength((BytesMessage) message);
> >> +        } else if (message instanceof TextMessage) {
> >> +            // TODO: Converting the whole message to a byte array is
> too
> >> much overhead just to determine the message size.
> >> +            //       Anyway, the result is not accurate since we don't
> >> know what encoding the JMS provider uses.
> >> +            return ((TextMessage) message).getText().getBytes().length;
> >> +        } else {
> >> +            log.warn("Can't determine size of JMS message; unsupported
> >> message type : "
> >> +                    + message.getClass().getName());
> >> +            return 0;
> >> +        }
> >> +    }
> >> +
> >>     public static <T> T lookup(Context context, Class<T> clazz, String
> >> name)
> >>         throws NamingException {
> >>
> >>
> >>
> >>
> >
>

Reply via email to