Skip to Content


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

/wp-content/uploads/2012/05/rule_create_consumer_1_98888.png

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

/wp-content/uploads/2012/05/rule_consumer_for_rule_created_2_98889.png

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

/wp-content/uploads/2012/05/rule_get_alerts_98890.png

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

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Stefan DrechรŸler

    Hello Michal,

    we got this error during the web service execution.

    Fehlgeschlagen
    3/27/13 3:56:12 PM CET
    Inbound
    {http://sap.com/xi/BASIS/alerting/api2}AlertRetrieveAPI_V2
    WS
    -392eddb6:13da693a7e1:-7f8c

    parseRequest
    invokeEndpoint
    createResponse
    sendResponse
      
    process()
    [EXCEPTION]
    com.sap.engine.interfaces.webservices.runtime.ProtocolExceptionExt: Authentication failed. For details see log entry logID=C0000AFA165520DF0000000001A7002A in security log.
    at com.sap.engine.services.wssec.srt.protocols.ProviderSecurityProtocol.logThrowable(ProviderSecurityProtocol.java:1210)
    at com.sap.engine.services.wssec.srt.protocols.ProviderSecurityProtocol.handleRequest(ProviderSecurityProtocol.java:527)
    at com.sap.engine.services.webservices.espbase.server.runtime.ProtocolProcessor.protocolsHandleRequest0(ProtocolProcessor.java:95)
    at com.sap.engine.services.webservices.espbase.server.runtime.ProtocolProcessor.protocolsHandleRequest(ProtocolProcessor.java:70)
    at com.sap.engine.services.webservices.espbase.server.runtime.RuntimeProcessingEnvironment.preProcess(RuntimeProcessingEnvironment.java:483)
    at com.sap.engine.services.webservices.espbase.server.runtime.RuntimeProcessingEnvironment.process(RuntimeProcessingEnvironment.java:322)
    at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPostWOLogging(ServletDispatcherImpl.java:199)
    at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:65)
    at com.sap.esi.esp.application.SoapServlet.doPost(SoapServlet.java:53

    The user has this role SAP_XI_ALERT_CONSUMER.

    Any idea?

    Best regards,

    Stefan

    (0) 
  2. 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”

    Thanks

    Kind regards.

    (0) 
  3. Ameet Kamat

    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

    Ameet

    (0) 
  4. 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.

    Regards

    Juan 

    (0) 
  5. Shubhnam Bhamber

    Hi Michal,

    Nice blog as usual ๐Ÿ™‚

    Thanks!

    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) ๐Ÿ™‚

    rgds

    (0) 
  6. mithali rathi

    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.

    (0) 
  7. 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 !

    (0) 
  8. RAVIJEET DAS

    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


    Thanks

    Ravijeet

    (0) 

Leave a Reply