cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Single Interceptor for In/Outbound Message
Date Thu, 23 Sep 2010 13:20:27 GMT
On Thursday 23 September 2010 8:43:33 am Peter.Neu@gmx.net wrote:
> What I need to time is the request entry time and how long it takes to
> process the business logic in the middleware. I got some nasty backend
> calls which can be pretty time-consuming. So what I need to know is when
> does the processing of the response continue.
> 
> Isn't the else statment displaying this when I configure the interceptor
> for both in and outbound calls?

Yep, but not completely.  (BTW:  It would be easier to just user:
if (MessageUtils.isOutbound(message)) {
....
} else {
....
}

The issue is that on the INBOUND side, the POST_LOGICAL phase occurs after the 
HTTP connection has been created, the data is sent, the soap processing is 
done, and the JAXB (assuming JAXB) objects have been unmarshalled.   Thus, the 
time for those actions would not be part of your calculations.   Likewise, on 
the OUTBOUND side, the actual marshalling of the response and sending it back 
to the client would not be included.   

That said, from you desicription, it sounds like you don't need/want that 
information anyway  so what you have would like work perfectly.


One more note:  

The line:
addAfter(ReadHeadersInterceptor.class.getName());

is irrelevant as the ReadHeadersInterceptor doesn't live in the POST_LOGICAL 
phase.  I'd just remove it.

Dan




> 
> Anyway will look into the CounterRepository.
> 
> Cheers,
> Pete
> 
> 
> -------- Original-Nachricht --------
> 
> > Datum: Fri, 17 Sep 2010 14:38:20 -0400
> > Von: Daniel Kulp <dkulp@apache.org>
> > An: users@cxf.apache.org
> > CC: Peter.Neu@gmx.net
> > Betreff: Re: Single Interceptor for In/Outbound Message
> > 
> > On Thursday 16 September 2010 2:26:58 am Peter.Neu@gmx.net wrote:
> > > OK. Got it. So I will not further follow this approach.
> > > 
> > > Maybe this solution is more straightforward. I'm just wondering if it
> > 
> > will
> > 
> > > work in a multiuser scenario?
> > 
> > It would work on the CLIENT side, yes (although USER_LOGICAL is probably
> > better).   On the server side, it would only log the time around the
> > invoke of
> > the service, not all the stuff CXF would do such as reading/writing,
> > handling
> > ws-security, etc...   Guess it depends on what you want to time.  :-)
> > 
> > That said, have you looked at the ResponseTimeFeature we already have in
> > CXF?
> > 
> > http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/ap
> > ache/cxf/management/interceptor/
> > 
> > (which, apparently isn't documented)
> > 
> > However, there is some very minimal docs at the bottom of:
> > http://cxf.apache.org/docs/jmx-management.html
> > about the counter repository stuff.
> > 
> > 
> > Dan
> > 
> > > super(Phase.POST_LOGICAL);
> > > 
> > > 	addAfter(ReadHeadersInterceptor.class.getName());
> > > 
> > > }
> > > 
> > > public void handleMessage(SoapMessage message) throws Fault {
> > > 
> > > 	Exchange ex = message.getExchange();
> > > 	
> > > 	if (message.getVersion() instanceof Soap11) {
> > > 	
> > > 	Map<String, List<String>> headers = CastUtils.cast((Map)
> > > 	
> > >         message.get(Message.PROTOCOL_HEADERS));
> > > 	
> > > 	if (headers != null) {
> > > 	List<String> sa = headers.get("SOAPAction");
> > > 	if (sa != null && sa.size() > 0) {
> > > 	String action = sa.get(0);
> > > 	
> > >            if (action.startsWith("\"")) {
> > > 	  
> > > 	  action = action.substring(1, action.length() - 1);
> > > 	  
> > > 	   }
> > > 	
> > > 	System.out.println("[STATISTICS] [action] " + action);
> > > 	ex.put("startTime", System.currentTimeMillis());
> > > 	
> > > 			}
> > > 	
> > > 	}
> > > 	
> > >         else {
> > > 	
> > > 	long diff = System.currentTimeMillis()
> > > 	
> > >                     -Long.valueOf(ex.get("startTime").toString());
> > > 	
> > > 	long diffMs = diff % 1000;
> > > 	
> > >         System.out.println("[STATISTICS] [duration]"+ diffMs + " ms");
> > > 		
> > > 		}
> > > 	
> > > 	}
> > > 
> > > }

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

Mime
View raw message