You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Je...@cox.com on 2009/03/25 19:28:32 UTC

CXF and JAMON integration?

Has anyone integrated CXF and JAMon (http://jamonapi.sourceforge.net/) successfully? I would like to track web service hits using JAMon but I don't know where to *centralize* the code. We are converting an existing XML over HTTP app to SOAP using CXF. In the current app we have a central point of control in our Servlet ( every call goes through this servlet ) so we trap it there and log the hit in JAMon. We know which request handlers are hit and how long it takes to respond. With SOAP and CXF the stack (CXFServlet) is the central point of control and I don't know where to trap the calls and the duration. I am pretty sure it will be in an *interceptor* but which one?

When I dump the inbound SOAP message I see the <Action> element in the log. But when I try get at this <Action> element programmatically I only get "".

<Action xmlns="http://www.w3.org/2005/08/addressing">http://server.cxf.asi.cox.com/CustomerService/getCustomers</Action>

Any thought are greatly appreciated.

What I did:

I created a "StatisticsInterceptor" that extends SoapActionInInterceptor
In the handleMessage(SoapMessage message) method I tried to get a the SOAP_ACTION and I get and empty string including the quotes.

StatisticsInterceptor:75 - SOAP_ACTION [""]


         Map<String, List<String>> headers =
            CastUtils.cast(
               ( Map ) message.get( Message.PROTOCOL_HEADERS ) );

         List<String> sa =
             headers.get(SoapBindingConstants.SOAP_ACTION);

         for ( String s : sa )
         {
             logger.debug("SOAP_ACTION [" + s + "]");
         }



Jeffrey M. Constantin | Cox Communications Inc.
Data Product Services (DPS) | Architecture & Systems Integration (ASI)
Desk: 404-269-3111 | Mobile: 678.643.6528





Re: CXF and JAMON integration?

Posted by Daniel Kulp <dk...@apache.org>.
On Wed March 25 2009 2:28:32 pm Jeffrey.Constantin@cox.com wrote:
> Has anyone integrated CXF and JAMon (http://jamonapi.sourceforge.net/)
> successfully? I would like to track web service hits using JAMon but I
> don't know where to *centralize* the code. We are converting an existing
> XML over HTTP app to SOAP using CXF. In the current app we have a central
> point of control in our Servlet ( every call goes through this servlet ) so
> we trap it there and log the hit in JAMon. We know which request handlers
> are hit and how long it takes to respond. With SOAP and CXF the stack
> (CXFServlet) is the central point of control and I don't know where to trap
> the calls and the duration. I am pretty sure it will be in an *interceptor*
> but which one?

The BEST option is to look at the ResponseTime interceptors and stuff that we 
already have in the cxf-rt-management module.   They currently feed out 
through JMX, but you could probably extend it out to feed to JAMon.   Either 
that or just take the interceptors and modify the code as needed.


> When I dump the inbound SOAP message I see the <Action> element in the log.
> But when I try get at this <Action> element programmatically I only get "".

What you did would get the SOAPAction HTTP header, not the ws-addressing 
header.   The easiest would be AFTER the ws-addressing interceptors run, do:

AddressingProperties inProps = (AddressingProperties)message
                .getContextualProperty(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
and grab the action from there. 

Alternatively:

soapMessage.getHeaders() returns a List<Header> which is the headers in the 
SOAP message.   You can iterate over that to find the header you need.

Dan


>
> <Action
> xmlns="http://www.w3.org/2005/08/addressing">http://server.cxf.asi.cox.com/
>CustomerService/getCustomers</Action>
>
> Any thought are greatly appreciated.
>
> What I did:
>
> I created a "StatisticsInterceptor" that extends SoapActionInInterceptor
> In the handleMessage(SoapMessage message) method I tried to get a the
> SOAP_ACTION and I get and empty string including the quotes.
>
> StatisticsInterceptor:75 - SOAP_ACTION [""]
>
>
>          Map<String, List<String>> headers =
>             CastUtils.cast(
>                ( Map ) message.get( Message.PROTOCOL_HEADERS ) );
>
>          List<String> sa =
>              headers.get(SoapBindingConstants.SOAP_ACTION);
>
>          for ( String s : sa )
>          {
>              logger.debug("SOAP_ACTION [" + s + "]");
>          }
>
>
>
> Jeffrey M. Constantin | Cox Communications Inc.
> Data Product Services (DPS) | Architecture & Systems Integration (ASI)
> Desk: 404-269-3111 | Mobile: 678.643.6528

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

RE: CXF and JAMON integration?

Posted by Je...@cox.com.
FYI:



Found the solution: Spring has a JamonPerformanceMonitorInteceptor you can easily wire into your web services beans as follows.

This is an Aspect Oriented Programming (AOP) solution that works great. For every method call in my bean we get stats like hits, execution time, min and max time, and etc.



This is a very good use of AOP and an easy implementation. Thanks Spring!!!


      <!-- BEANS -->
      <bean id="serviceBean" class="com.ws.CustomerServiceImpl" />



      <!-- wire the Advice -->

      <bean id="jamonInterceptor"

            class="org.springframework.aop.interceptor.JamonPerformanceMonitorInteceptor">

      </bean>



      <!-- wire the PointCut -->

      <bean id="jamonPointcut"

            class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">

            <property name="advice">

                  <ref local="jamonInterceptor" />

            </property>

            <property name="patterns">

                  <list>

                        <value>.*</value>

                  </list>

            </property>

      </bean>



   <!-- wire the Bean and the PointCut together -->

      <bean id="jamonProxyCreator"

            class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">

            <property name="beanNames">

                  <value>serviceBean</value>

            </property>

            <property name="interceptorNames">

                  <list>

                        <value>jamonPointcut</value>

                  </list>

            </property>

   </bean>



-----Original Message-----
From: Jeffrey.Constantin@cox.com [mailto:Jeffrey.Constantin@cox.com]
Sent: Wednesday, March 25, 2009 2:29 PM
To: users@cxf.apache.org
Subject: CXF and JAMON integration?



Has anyone integrated CXF and JAMon (http://jamonapi.sourceforge.net/) successfully? I would like to track web service hits using JAMon but I don't know where to *centralize* the code. We are converting an existing XML over HTTP app to SOAP using CXF. In the current app we have a central point of control in our Servlet ( every call goes through this servlet ) so we trap it there and log the hit in JAMon. We know which request handlers are hit and how long it takes to respond. With SOAP and CXF the stack (CXFServlet) is the central point of control and I don't know where to trap the calls and the duration. I am pretty sure it will be in an *interceptor* but which one?



When I dump the inbound SOAP message I see the <Action> element in the log. But when I try get at this <Action> element programmatically I only get "".



<Action xmlns="http://www.w3.org/2005/08/addressing">http://server.cxf.asi.cox.com/CustomerService/getCustomers</Action>



Any thought are greatly appreciated.



What I did:



I created a "StatisticsInterceptor" that extends SoapActionInInterceptor

In the handleMessage(SoapMessage message) method I tried to get a the SOAP_ACTION and I get and empty string including the quotes.



StatisticsInterceptor:75 - SOAP_ACTION [""]





         Map<String, List<String>> headers =

            CastUtils.cast(

               ( Map ) message.get( Message.PROTOCOL_HEADERS ) );



         List<String> sa =

             headers.get(SoapBindingConstants.SOAP_ACTION);



         for ( String s : sa )

         {

             logger.debug("SOAP_ACTION [" + s + "]");

         }







Jeffrey M. Constantin | Cox Communications Inc.

Data Product Services (DPS) | Architecture & Systems Integration (ASI)

Desk: 404-269-3111 | Mobile: 678.643.6528