Recently I started to wonder how to get message content and audit logs for message after processing in Adater Engine. If Message comes to PI, usually is processed in Abap stuck and there everything seems to be rather clear. We have some function modules like
Or we can check main tables like
SXMSPMAST XI Messages – Master
SXMSPVERS Integration Engine: Message Version
SXMSCLUP Cluster – Compressed Message Payload Property
As a last resort we can debug sxi_monitor transaction to receive message data, current status or payload. But how can we get those values from Java stuck. Of course we can read table data
XI_AF_MSG AF XI Message
XI_AF_MSG_AUDIT Audit Log Entries
But it is not the solution and sometimes data aren’t kept in human readable format like payload is kept in blob format.
In PI 7.1 we have standard WebService like described in Michael’s blog. Disadvantage of this solution is that we do not receive Audit Log for processed message and this WebService in not available for PI 7.0.
Let suppose I would like to build some external tool to trace selected message’s flow. I will receive information about errors in Abap stuck through CCMS and in Java stuck with Alert mechanism. But it’s not enough for me. I would like to have full information about message and Audit Log in java based on message id.
First approach – Java DB tables
Read Java tables – not acceptable
Second approach – Jar files
So I started to check what kind of possibilities I have. First of all I downloaded some jar files from PI server and checked what kind of class and methods they offer.
To receive information about Message I discovered in aii_af_ms_impl.jar file, class MessageStore and method getMemoryMessageBeans(MessageBeanFilter filter) where MessageBeanFilter is filter similar to this with we set in http://<server>:<port>/mdt/index.jsp .
In aii_af_svc.jar file I have class AuditLogManger. So at the beginning I started to use method getAuditEntryList(AuditMessageKey msgKey) but I receive error message. After struggling with AuditLogManager class I receive in my WebService correct result and the problem was with Connection class that provide access to Java Database. But this method seems to be very raw and unreliable but at least it was working. I started to search more and discovered some very nice Enterprise Java Beans offered by our J2EE server with is SAP Netweaver.
Third approach – Enterprise JavaBeans
In NWA i have list of all available modules and assigned to it Enterprise JavaBeans. I’m interested in module aii_af_ms_app_ejb.
Inside this module i will find EJB with I’m particularly interested in and there name is messaging.system.MonitorBean and messaging.system.AuditLogBean
Let’s now focus on MonitorBean with I will use to fetch message detail from PI. As each bean this one has JNDI used for search it in lookup and interface MonitorHI that allow WebService to obtain reference to specific bean.
EJB functionality is accessed by means of remote interface, which define the business methods visible to, and called by WebService. MonitorRI interface contains lot of very use full methods and is implemented by MonitorBeanImpl. Some use full methods:
MessageBean getMessageBean(MessageKey paramMessageKey, int paramInt) – return message details for message key ( consists of message id and message direction)
byte getMessageBytes(MessageKey paramMessageKey, int paramInt) – return whole XI Message with payload.
MonitorBean getMonitorBean(MessageBeanFilter paramMessageBeanFilter) – return all messages that fulfil requirements set in MessageBeanFilter, that contains additional criteria for filter like interface name, sender service etc.
Similar for AuditLogBean I will use interface AuditLogBI and method
ArrayList getLogEntries(AuditMessageKey paramAuditMessageKey, int paramInt)
-return all AuditLogEntry for selected auditMessageKey( consist of message id and message key)
After download jar files that contains those class from J2EE server i can start building WebService. There are plenty of tutorials on SDN how to build java WebService from EJB.
In my bean i had to add some references etc.
Method code to receive Message details
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup(“messaging.system.MonitorBean”);
if( obj != null)
_mhi = (MonitorHI) obj;
_monb= (MonitorBI) _mhi.create();
Home interface MonitorHI can be used to execute method create() and receive Remote interface MonitorRI. This interface type extends MonitorBI interface so we can cast it to MonitorBI or use MonitorRI
Next step it to call requested method like
MessageKey _mk = null;
MessageDirection _mess_dir = null;
_mess_dir = MessageDirection.INBOUND;
_mk = new MessageKey(“YOUR MESSAGE ID”,_mess_dir);
MessageBean _result = null;
_result = _monb.getMessageBean(_mk,i_cluster);
Where _mk is MessageKey and i_cluster is int variable that contain node/cluster id and can be omitted with value 0.
Similar approach can be used to receive array of AuditLogEntry
Log on to Wsnavigator and test WebServices