Skip to Content
Author's profile photo Michal Krawczyk

Michal’s PI tips: Component based message alerting – API

In my previous article – Michal’s PI tips: Component-Based Message Alerting – I’ve introduced the new Component Based Message Alerting which is available as of EhP1 for PI 7.3. I’ve also shown how to configure a sample java based e-mail consumer. Using a java based e-mail consumer is just one of the ways to receive alerts from this new component as we can also do the same using the available API. This ariticle will show how to use the Component-Based Message Alerting in order to create a consumer and consume alerts generated inside SAP PI.

Step 1

Create an alert rule and specify which types of error messages should be reported for this rule as shown in Step 1 and 2 of my previous article – Michal’s PI tips: Component-Based Message Alerting

Step 2

Now instead of using the standard ALERT-TO-MAIL consumer we will create a new one using the API. You can do it from any WS enabled application but in this article we will use web service navigator to invoice all necessary API services. To add a new consumer we will use – RegisterConsumer – web service.

As per Figure below you just need two parameters to invoke this Rule:

a) AlertRuleID – which is the name of the rule created in ID

b) ConsumerName – which will be the name of the consumer


If everything is correct your consumer will be visible in ID as per Figure below.


For more info on this step (on parameters, authorizations necessary to perform the steps please have a look at: Subscribing Consumers to Alert Rules (RegisterConsumer)

Step 3

Now we’re ready to query to rule in order to check if there are any new alerts. You can do this using RetrieveSingleAlerts web service and the only 2 parameters you need to use are:

a) ConsumerID – the same one as specified in Step 2 of this article

b) MaxAlerts – maximum number of alerts fetched during one API call



As you can see once you get the alert info for a specific consumer it’s not possible to retrieve it once more as you do not put any date ranges in the RetrieveSingleAlerts API. So while building your application please keep in mind that you can only get the alerts once and it will not be available during the next call.

For more info on this step (on parameters, authorizations necessary to perform the steps please have a look at: Alerting API on Alert Engine


As you can see the Component-Based Message Alerting is very simple to use and can be quite quickly used in all applications which support Web Service calls. There are a few more methods available like one for unsubscribing the consumers, checking runtime components for a specific rule, etc. and you can find more info about them at: Alerting API on Integration Directory

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Stefan Drechßler
      Stefan Drechßler

      Hello Michal,

      we got this error during the web service execution.

      3/27/13 3:56:12 PM CET

      [EXCEPTION] Authentication failed. For details see log entry logID=C0000AFA165520DF0000000001A7002A in security log.

      The user has this role SAP_XI_ALERT_CONSUMER.

      Any idea?

      Best regards,


      Author's profile photo Carlos Ocampos
      Carlos Ocampos

      Hi Michal,

      Thanks a lot for your fantastic blog, as usual!

      Just one comment:

      To create a new Consumer, I think you don't need to use Webservice AlertRuleIn with RegisterConsumer operation. Just when you are creating Alert Rule in Integration Directory, press the icon to Insert Consumer and in the new line  type the name of the consumer manually and press enter.(Don't use F4 for value list)

      I did this and it works. Actually  I did this, and after that I used AlertRuleIn->RegisterConsumer and I got a message like:

      "Consumer PI_AT_ALL already registered"


      Kind regards.

      Author's profile photo Binod Mondal
      Binod Mondal

      This worked for me too... Thanks Carlos for your tips.. 🙂

      Author's profile photo Former Member
      Former Member

      Hi Michal,

      Nice blog. However can we raise an alert by acccessing this API or can only subsribe to existing alerts. e.g. For dual stack, we use to call standard FM SALERT_CREATE to raise alerts incase of any errors in proxy processing as well. Can we have similar functionality atleast for Java based applications or by doing a WS call?

      Thanks and Regards


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

      Hi Michal,

      Question :

      When using pi + bpm we know that we can setup alerting so that when a message on PI fails and alert is triggered.

      This means also that without active monitoring of the PI queue mesg monitoring (Java Only) you would still be notified when an error occurred on PI via the alerting framework.

      What can be done when the end to end solution includes some processing within a BPM and an error occurs in the BPM (eg mapping error).

      The best solution would be that an alert is also raised.

      Is this possible and if not how can the monitoring be done without actively logging on to the PI system and opening the process overview and searching for error cases?

      thanks for your input.

      Nice post btw.



      Author's profile photo Shubhnam Singh
      Shubhnam Singh

      Hi Michal,

      Nice blog as usual 🙂


      Quick question: Can we have subscription based on Roles/profile with CBMA? Also if a person can subscribe/unsubscribe?

      Since this info can be included in your blog, I am not posting in the forum (which u  recommend strictly) 🙂



      Author's profile photo Former Member
      Former Member

      Hi Michal,

      I wanted to change the format & body of the Alert . I did read your blog. Its not mentioned in how to Edit the alert message. Can you help with that.

      Author's profile photo Carlos Ocampos
      Carlos Ocampos

      Hi Mithali ,

      I think you can read following blogs to customize e-mail body in Alerts:

      Customize E-Mail Body and Subject in Alerts in SAP PI 7.31 – Java Stack Only – Part 1 – ESR

      Customize E-Mail Body and Subject in Alerts in SAP PI 7.31 – Java Stack Only – Part 2 – ID

      Hope it will help.

      Have a nice day,

      Best regards

      Author's profile photo Lucila Isernia
      Lucila Isernia

      Hello Michal,

      I created a new rule and registered the new consumer like you said in this blog.
      I have scheduled a job, but the the job is not successfully performed an alert when I have error in the interface..

      But if I give one consumer that we have for another rule created before, the job is successfully performed an alert  when the interface have error.

      We have to configure the consumer in another part for example solman?.

      thanks !

      Author's profile photo Former Member
      Former Member

      Hi Michael,

      I see if you give the consumer name for the Alert ID and activate in Integration directory or NWDS. Consumer for the Alert ID automatically creates, no need to call the web-service "RegisterConsumer" to create the consumer. Similarly you can deregister the customer consumer by deleting the consumer name from the Alert ID and activate.

      I believe SAP help needs to modify with these steps