Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
MichalKrawczyk
Active Contributor


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

Note:

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

Conclusion:

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

11 Comments