Skip to Content
Author's profile photo Michal Krawczyk

PI/XI: target message logging with local AAE not possible ? not anymore…

As you all probably know while using local Advanced Adapter Engine (AAE) processing in SAP PI 7.1 the message is logged only once (during processing by sender adapter). This is great in terms of performance but what if we need to check the mapping output? Is there a way do do it somehow? It turns out that we don’t have such an option in standard yet. Is there any alternative then?

It turns out there is – a simplest adapter module there is…

Local AAE works in such a way that from the sender adapter it executes the receiver adapter so in the outbound message to PI processing you can see the adapter info logs of the receiver adapter and this is what we can use. The idea is to add an adapter module to the receiver adapter which will put the content of the message into the audit log of PI message processing. We can do it by writing a few lines of code:

 import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext; // Classes for Module development & Trace
import com.sap.aii.af.lib.mp.module.*;
import com.sap.engine.interfaces.messaging.api.*;
import com.sap.engine.interfaces.messaging.api.auditlog.*;

public class LogAdapterXMLBean implements SessionBean, Module {
 
 private SessionContext myContext;

 public void ejbRemove() {
 }

 public void ejbActivate() {
 }

 public void ejbPassivate() {
 }

 public void setSessionContext(SessionContext context) {
  myContext = context;
 }

 public void ejbCreate() throws CreateException {
 }

 public ModuleData process(ModuleContext moduleContext,
   ModuleData inputModuleData) throws ModuleException {

  AuditAccess audit = null;

  Object obj = null;
  Message msg = null;

  MessageKey key = null;
  try {
   obj = inputModuleData.getPrincipalData();
   msg = (Message) obj;
   key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());
   audit = PublicAPIAccessFactory.getPublicAPIAccess()
     .getAuditAccess();
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
     “Set this: Module called”);
   
   XMLPayload xmlpayload = msg.getDocument();
   
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
   “Below the content of the message”);
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
   xmlpayload.getText());
   
   
  } catch (Exception e) {
   ModuleException me = new ModuleException(e);
   throw me;
  }
 
  return inputModuleData;
 }

}

 

Then we just need to add the adapter module to our receiver communication channel which is using local AAE.

and Voilà – we should see the content of the target message in the audit section of the sender communication channel.

And the best part of that is that we can easily turn it ON and OFF whenever we like so it will not affect performance during life scenarios.

Please let me know if you like this idea 🙂

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      I think its a great idea 😉

      Thanks and keep it up. Everyday I am always checking for your new blogs 🙂

      Kind Regards
      Arman

      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author
      Hi Arman,

      thank you:)

      Regards,
      Michal Krawczyk

      Author's profile photo Former Member
      Former Member
      Michal,
      Excellent idea as usual 🙂

      Any thoughts on the detailed mapping trace in case of errors. It seems that AAE does not display the mapping trace (standrad/user added trace) in detail in the audit log.

      Thanks,
      Sudharshan N A

      Author's profile photo Former Member
      Former Member
      Very Helpfull as always
      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author
      thank you 🙂

      Regards,
      Michal Krawczyk

      Author's profile photo Former Member
      Former Member
      Hi Michal

      Great idea!!! (Do I need to say as usual, isn't that a given in Michal's blogs?)

      Just wondering what is the logic behind getting the target message in sender channel? Should this not be part of Reciverf channel? What am I missing?

      Please enlighten

      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author
      hi,

      >>>Just wondering what is the logic behind getting the target message in sender channel? Should this not be part of Reciverf channel? What am I missing?

      there is no receive channel logging in "local AAE" - message is logged only once - in the sender channel 🙂

      Regards,
      Michal Krawczyk

      Author's profile photo Former Member
      Former Member
      Its indeed a great blog and resolves a few of the anxious queries which we have with AAE.
      The other issue which we face is seeing mapping errors in AAE scenarios. How do we get that?

      Yash

      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author
      Hi,

      >>>The other issue which we face is seeing mapping errors in AAE scenarios. How do we get that?

      will let you know 🙂

      Regards,
      Michal Krawczyk

      Author's profile photo Former Member
      Former Member
      Please do.. will wait for that Michal!
      Author's profile photo Former Member
      Former Member
      Hi Michal,

      Any update on how to catch mapping errors in AAE scenarios in PI 7.1x (not 7.3 which is the talk of the town nowadays :))!

      - Yash

      Author's profile photo Anupam Ghosh
      Anupam Ghosh

      Hi Michal,

                      Excellent article.

      Loving this.

      Regards

      Anupam

      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author

      thank you Anupam,  

      Regards,

      Michal Krawczyk