As transformations are dictated by the set of filters/handlers in your configuration, they are not always trivial, it’s becoming very important quickly to capture the messages at different phases of the processing.
See the flow
First thing to understand when trying to debug a configuration is “where the hell are all my messages going ?” :)
This is achievable simply by activating DEBUG
traces in your LogSink
heap object:
When the DEBUG
traces are on
, you should see something like:
You’ll see a new line each time an Exchanges comes into a Handler/Filter and each time it’s flowing out of the element (you also get a performance measurement).
Capture the messages (requests/responses)
OpenIG provides a simple, way to see the HTTP message (being a
request or a response), including both headers and (optionaly) the entity (if
that’s a textual content): the CaptureFilter
.
Here is an output example you can obtain when you install a CaptureFilter
:
Install a CaptureFilter
Being a filter, it has to be installed as part of a Chain:
It is usually best placed either as the OpenIG entry point (the first element
to be invoked), that helps to see what the User-Agent sends and receives (as
it’s perceived by OpenIG) or just before a ClientHandler
(that represents
a sort of endpoint, usually your protected application).
Capture what you want
CaptureFilter
is sufficient for simple capturing needs. When what you want
to observe is not contained in the HTTP message, we have to use the OpenIG
swiss-knife: ScriptableFilter
.
This is a special filter that allows you to execute a Groovy script when traversed by an Exchange.
Here is a sample script that prints the content of the Exchange’s session:
Copy this script into ~/.openig/scripts/groovy/PrintSessionFilter.groovy
and configure your heap object:
Seeing the messages on wire
Sometimes, all of the previous solutions are not applicable, because you want to see the on-wire message content (as opposed to modelled by OpenIG).
For this case, the only solution is to start your OpenIG with a couple of system properties that will activate deep traces of the http client library we’re using: Apache HTTP Client.
>$ bin/catalina.sh -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \
-Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug \
-Dorg.apache.commons.logging.simplelog.log.org.apache.commons.httpclient=debug \
run
See the HTTP Client Logging page for more informations.
Next
In the next post we’ll explain how routes can speed-up your configuration preparation.