This blog describes how to retrieve information about messages from a PI system. PI has several interfaces which can be used to retrieve PI messages and other data from the system.
To read messages from a PI System, we have different solutions for Java and ABAP. They are not released as stable APIs and we don’t give assurance that it will never change. However, the APIs are usually stable in a release (and available since NetWeaver 7.0) and can be used to retrieve the data. Depending if the messages are retrieved from Java (Adapter Engine) or ABAP (Integration Engine) stack, there are different technologies. A web service can be used for the Java stack and ABAP function modules for the ABAP stack.
We offer a web service to retrieve messages from Java stack. The web service offers similar functionality to what can be done in the RWB Message Monitoring tool:
This can be done with the web service AdapterMessageMonitoringVi which is delivered with a standard PI installation and is available with all releases. In 7.10, please check note 1373289 for availability limitations. The web service can be investigated and tested with the Web Services Navigator tool of the WebAS Java.
Web service WSDL URL is available at:
http://<host>:<port>/AdapterMessageMonitoring/basic?wsdl&mode=ws_policy&style=document
The web service also offers three different bindings for basic Http authentication, SSL over Https and HTTPS with client certificate authentication.
The actual web service URL depends on which binding is to be used and can be one of the follows:
http://<host>:<port>/AdapterMessageMonitoring/basic?style=document
https://<host>:<httpsport>/AdapterMessageMonitoring/ssl?style=document
https://<host>:<httpsport>/AdapterMessageMonitoring/clientCert?style=document
In most cases the basic binding can be used if no special security requirements must be met.
The web service offers a set of operations/methods for different purposes. Some interesting methods for message monitoring are:
The web service also contains other methods, e.g. cancelMessage and resendMessage that can be used for message manipulation, but are not required for monitoring purposes. In newer releases like 7.30 and 7.31 the web service AdapterMessageMonitoringVi even contains many more methods for advanced monitoring (e.g. can be used for User-Defined Message Search) but which are out of scope for this document.
The method getMessageList can be used to search for messages which match to a given filter. This is according to the search functionality in RWB Message Monitoring.
The method has two input parameters:
The input structure for parameter filter contains many attributes of PI messages which are used to search for specific messages.
Important filter fields are:
Unused filter fields can be left empty so that they are not considered during the search. An example for a valid filter which searches messages with error status in a certain time interval can look like in the following screenshot:
Only fromTime, toTime and status are provided here. All other filter attributes are left empty and thus ignored.
The result of method getMessageList contains a structure with all search results, and for each result the message header information. An important field in the result structure is messageKey, because this field contains the input value which is required as input for the other methods getMessagesByKeys, getMessageBytesJavaLangStringBoolean and getMessageBytesJavaLangStringIntBoolean.
The following picture shows a part of the result:
The result contains an array of AdapterFrameworkData with one entry for each message that matched the filter.
This method works similar to method getMessageList. It returns a list of messages and their header attributes, but without the message payload. The only difference between the two methods is that it has only a list of message keys as input parameters.
This message keys have to be in the following format:
<guid>\<direction>\<node>\<QoS>\<seqNr>\
(Please note the backslash “\” at the end. It’s important to add it!)
An example for a valid message key is like this:
5ba9192c-fa6c-11e0-ca61-00001001a6a3\INBOUND\268543650\EO\0\
An invalid message key would be:
5ba9192c-fa6c-11e0-ca61-00001001a6a3\\\EO\\
(all 5 parameters needs to be filled in the message key)
Please note: Only the fields guid and direction are really of importance here. All other fields can have “random” values (but the values should stay in the same parameter type; e.g. server node has to be integer, QoS has to be one of “EO”, “BE”, “EOIO”, etc.)
The two methods getMessageBytesJavaLangStringBoolean and getMessageBytesJavaLangStringIntBoolean can be used to retrieve the payload of a message. Both methods work very similar, only the second method has an additional parameter for the message version (method one always returns the latest message version).
The other input parameters are
The result of this method contains a byte array with the serialized payload of the PI message. It can be deserialized and afterwards processed. For example it can be (depending on the payload type) parsed as XML document to extract several elements of the XML. In the code this can look similar to this:
// call web service to get data
byte[] msgBytes = adapterMessageMonitoringWS. getMessageBytesJavaLangStringBoolean(…);
// parse result
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new ByteArrayInputStream(msgBytes), new MySAXHandler());
This method can be used to retrieve the Audit Log entries of a PI message. It has 5 input parameters:
The return value contains a list with the Audit Log entries for the message with the timestamp, severity, text and some other data.
There are two important function modules to read the messages from the ABAP stack:
Both function modules are remote enabled and can be called externally, e.g. via JCO from a Java application. The functionality of the function modules is similar to the Java web service methods.
The function module can be used to search for messages which match to a given filter. This is according to the search functionality in RWB Message Monitoring or SXMB_MONI.
Input and output parameters of the function module:
Input parameters:
The data type SXI_MESSAGE_FILTER for the filter has the following important fields:
01 Successful
03 Scheduled
05 Application Error
06 System Error
10 Branched
12 Waiting
19 Manually Modified
16 Retry
21 Canceled with Errors
30 Waiting for Confirmation
50 Log Version
Output parameter:
The function module returns the search result in output parameter EX_MESSAGE_DATA_LIST. This structure contains a list of results of type SXI_MESSAGE_DATA. It contains the header information for all found PI messages.
This function module can be called with the message ID (taken from the result of SXMB_GET_MESSAGE_LIST) and it returns the payload of the message. The result can be deserialized and further processed (e.g. parsed as XML document).
Input and output parameters of the function module:
Input parameter:
Output parameter:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
10 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |