how to view payload from an oracle esb

Introduction

Viewing the payload of an ESB instance within Oracle SOA suite is not available by default, at least not for successfully executed instances. But during development payload logging has proven extremely useful. And in production the concept of trackable fields have given insight into the core parts of the payload, even for successfully executed instances.
I will first explain how to enable payload logging, through a ESBLoggingInterceptor. And then how to utilize the trackable fields concept.

ESBLoggingInterceptor

Starting from Oracle Application Server release 10.1.3.4, ESB logging capability has been enhanced. To take advantage of this enhanced logging feature, you should perform the following steps:

  • implement the oracle.tip.esb.server.common.interceptor.IEsbMessageInterceptor interface.
  • Add the jar into the ESB classpath, for example: ORACLE_HOME/j2ee/oc4j_soa/server.xml, in block oracle.bpel.common
  • Add the following configuration variables in the esb_config.ini file:
  • inboundMessageInterceptor = no.gwr.esb.ESBLoggingInterceptor
    outboundMessageInterceptor = no.gwr.esb.ESBLoggingInterceptor

package no.gwr.esb;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;

import oracle.tip.esb.monitor.FlowId;
import oracle.tip.esb.server.common.interceptor.IEsbMessageInterceptor;

public class ESBLoggingInterceptor implements IEsbMessageInterceptor {

	private static final Logger log = LoggerFactory.getLogger(ESBLoggingInterceptor.class);
	private static String tab = "\t";

	public void invoke(FlowId flowId, String instanceId, Element payload, Element header, String serviceName, String systemName, Element response, Throwable throwable, boolean isOutbound,	boolean isResponse) {
		StringBuffer sb = new StringBuffer();
		sb.append("flowId: ").append(flowId).append(tab);
		sb.append("instanceId: ").append(instanceId).append(tab);
		sb.append("serviceName: ").append(serviceName).append(tab);
		sb.append("systemName: ").append(systemName).append(tab);
		if (header!=null)
			sb.append("headerContent: ").append(header.getTextContent()).append(tab);
		if (payload!=null)
		  sb.append("payloadContent: ").append(payload.getTextContent()).append(tab);
		if (response!=null)
			sb.append("response: ").append(response.getTextContent()).append(tab);
			System.out.println(sb.toString());//goes into default log
			log.info(sb.toString());//goes into the configured separate log
	}
}

As you notice sl4j is used for logging. This could be skipped, if you are happy with the default log for payload output. We separated this as we actually do payload logging also in production. This is to be able to scan historically executed payload content, as an audit log. A sample logback.xml could be:

<configuration>
 	<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<File>ESBInterceptor.log</File>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		  <FileNamePattern>ESBInterceptor.%d{yyyy-MM-dd}.log</FileNamePattern>
		   <MaxHistory>30</MaxHistory>
		</rollingPolicy>
		<layout class="ch.qos.logback.classic.PatternLayout">
			<Pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</Pattern>
		</layout>
	</appender>
   <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
    <Marker>PROFILER</Marker>
    <OnMatch>ALLOW</OnMatch><!--DENY-->
  </turboFilter>
  <root level="debug">
    <appender-ref ref="FILE" />
  </root>
</configuration>

Now payload is available in the ESBInterceptor.%d{yyyy-MM-dd}.log

In short:
To enable ESB Message Interceptor logging
1. Implement the oracle.tip.esb.server.common.interceptor.IEsbMessageInterceptor interface.
2. Add the implementation class into the ESB classpath. ie: server.xml/oracle.bpel.common
3. Add the Message Interceptor configuration variables in the esb_config.ini file
4. Restart the container for changes to take effect.

Trackable fields within ESB

The ESB trackable fields concept can be used to execute xpath-expressions. The way to do it is to deploy a ESB service, configure the trackable fields on the server, and then pull back the file *.esbsvc containing the relevant trackable fields expressions. This is to get the correct syntax of how to define trackable fields. Note that you must connect the trackable field to the correct operation guid, found elsewhere in the *.esbsvc-file.

The xpath is executed, and the trackable fields values are viewable in ESB console, in lower part of pane tracking.

...
  <trackableFields>
      <trackableField name="sourceSystem" status="ENABLED" bindTo="REQUEST">
         <operationRef guid="C31378D0FFAA11DEBFA619588F2E21CD" qname="ConsumerServices.EventsListener.EventsListener_v1_0.JmsAdapterIn_RS.Consume_Message"/>
         <expression>{/tns:eventsMessage/tns:messageBody/tns:sourceSystem};{ namespace tns=http://soa.gwr.no/shipping/v1.0/shipmentevents }</expression>
      </trackableField>
...

Summary

Now both the full payload is available in server logs, and a set of chosen payload values are available in ESB console.

References

@see Oracle bug 6995195
@see Oracle® Application Server Release Notes and New Features
10g Release 3 (10.1.3.4)

  • Trackback are closed
  • Comments (1)
  1. You control the location of log file by the log4j (or logback) configuration.
    The filename pattern is:
    ESBInterceptor.%d{yyyy-MM-dd}.log

    Did you use log4j or logback in ESBLoggingInterceptor.

    Could you send the snippet of esb_config.ini
    and ORACLE_HOME/j2ee/oc4j_soa/server.xml
    where you point to jar containing ESBLoggingInterceptor

Comment are closed.