What causes platform events to fail to be published and should I cater for failed platform event creations?Documentation Incorrect? Is it possible to cover/deploy triggers on Platform Events?Testmethod verification that @future published Platform EventTest that a Platform Event was published?Platform Events- Length of time an event is published for?Apex Rest Vs Platform Events for Inbound SF integration which one to choose?Platform Event throws RetryableException and then SFDC stops the trigger from consuming events for hoursUnable to subscribe to Platform Event Notifications in a Lightning Component via Lightning OutPlatform Event ReplayId - metadata says it is a String of length 1000 but evidence shows it as an integerError handling when publishing platform eventsPlatform Events and Transaction

Does hiding behind 5-ft-wide cover give full cover?

Hang 20lb projector screen on Hardieplank

How did Captain America use this power?

How could a planet have most of its water in the atmosphere?

How to back up a running Linode server?

What is the most remote airport from the center of the city it supposedly serves?

Transfer over $10k

How can I fairly adjudicate the effects of height differences on ranged attacks?

If Earth is tilted, why is Polaris always above the same spot?

My ID is expired, can I fly to the Bahamas with my passport

Accidentally deleted the "/usr/share" folder

How did Arya manage to disguise herself?

Is it cheaper to drop cargo than to land it?

Selecting a secure PIN for building access

What happened to Ghost?

Why are notes ordered like they are on a piano?

Is it the same airport YUL and YMQ in Canada?

If 1. e4 c6 is considered as a sound defense for black, why is 1. c3 so rare?

Why are there synthetic chemicals in our bodies? Where do they come from?

Meaning of "individuandum"

If Melisandre foresaw another character closing blue eyes, why did she follow Stannis?

How does NAND gate work? (Very basic question)

Why is this a valid proof for the harmonic series?

Applying a function to a nested list



What causes platform events to fail to be published and should I cater for failed platform event creations?


Documentation Incorrect? Is it possible to cover/deploy triggers on Platform Events?Testmethod verification that @future published Platform EventTest that a Platform Event was published?Platform Events- Length of time an event is published for?Apex Rest Vs Platform Events for Inbound SF integration which one to choose?Platform Event throws RetryableException and then SFDC stops the trigger from consuming events for hoursUnable to subscribe to Platform Event Notifications in a Lightning Component via Lightning OutPlatform Event ReplayId - metadata says it is a String of length 1000 but evidence shows it as an integerError handling when publishing platform eventsPlatform Events and Transaction






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








8















After examining docmentation I have began to create a platform event from Apex, but I have 3 unanswered questions when it comes to the creation of platform events concerning unsuccessfull publishing of a platform event.



For creation of a platform event, you can use the EventBus Class and the publish(events) method - which returns a database.saveresult. "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation". Based on this statement, one might wonder:



  • Because this is a database.saveresult, which can return a boolean 'saveResult.isSuccess', you can suspect that the creation of a platform event could also fail. What could cause a creation of a platform event to fail?

  • The saveresult is by default 'all or nothing', analogue to a database.Saveresult: "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation. It is similar in behavior to the Apex Database.insertmethod when called with the partial success option." Why would this be an 'all or nothing'? To me it doesn't make sense, since you'd always want all platform events to succeed and if they do fail, I want an exception or at least I want to know which events failed to be created and why.

Should I cater for the failing of the creation of platform events in my code? Or is this most likely to never happen? I could throw an exception or show the situations (records in this case) for which the event creations failed to an admin.
Thanks in advance for your help!










share|improve this question







New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 5





    This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

    – Derek F
    Apr 26 at 14:51

















8















After examining docmentation I have began to create a platform event from Apex, but I have 3 unanswered questions when it comes to the creation of platform events concerning unsuccessfull publishing of a platform event.



For creation of a platform event, you can use the EventBus Class and the publish(events) method - which returns a database.saveresult. "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation". Based on this statement, one might wonder:



  • Because this is a database.saveresult, which can return a boolean 'saveResult.isSuccess', you can suspect that the creation of a platform event could also fail. What could cause a creation of a platform event to fail?

  • The saveresult is by default 'all or nothing', analogue to a database.Saveresult: "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation. It is similar in behavior to the Apex Database.insertmethod when called with the partial success option." Why would this be an 'all or nothing'? To me it doesn't make sense, since you'd always want all platform events to succeed and if they do fail, I want an exception or at least I want to know which events failed to be created and why.

Should I cater for the failing of the creation of platform events in my code? Or is this most likely to never happen? I could throw an exception or show the situations (records in this case) for which the event creations failed to an admin.
Thanks in advance for your help!










share|improve this question







New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 5





    This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

    – Derek F
    Apr 26 at 14:51













8












8








8








After examining docmentation I have began to create a platform event from Apex, but I have 3 unanswered questions when it comes to the creation of platform events concerning unsuccessfull publishing of a platform event.



For creation of a platform event, you can use the EventBus Class and the publish(events) method - which returns a database.saveresult. "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation". Based on this statement, one might wonder:



  • Because this is a database.saveresult, which can return a boolean 'saveResult.isSuccess', you can suspect that the creation of a platform event could also fail. What could cause a creation of a platform event to fail?

  • The saveresult is by default 'all or nothing', analogue to a database.Saveresult: "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation. It is similar in behavior to the Apex Database.insertmethod when called with the partial success option." Why would this be an 'all or nothing'? To me it doesn't make sense, since you'd always want all platform events to succeed and if they do fail, I want an exception or at least I want to know which events failed to be created and why.

Should I cater for the failing of the creation of platform events in my code? Or is this most likely to never happen? I could throw an exception or show the situations (records in this case) for which the event creations failed to an admin.
Thanks in advance for your help!










share|improve this question







New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












After examining docmentation I have began to create a platform event from Apex, but I have 3 unanswered questions when it comes to the creation of platform events concerning unsuccessfull publishing of a platform event.



For creation of a platform event, you can use the EventBus Class and the publish(events) method - which returns a database.saveresult. "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation". Based on this statement, one might wonder:



  • Because this is a database.saveresult, which can return a boolean 'saveResult.isSuccess', you can suspect that the creation of a platform event could also fail. What could cause a creation of a platform event to fail?

  • The saveresult is by default 'all or nothing', analogue to a database.Saveresult: "The EventBus.publish() method doesn’t throw exceptions caused by an unsuccessful publish operation. It is similar in behavior to the Apex Database.insertmethod when called with the partial success option." Why would this be an 'all or nothing'? To me it doesn't make sense, since you'd always want all platform events to succeed and if they do fail, I want an exception or at least I want to know which events failed to be created and why.

Should I cater for the failing of the creation of platform events in my code? Or is this most likely to never happen? I could throw an exception or show the situations (records in this case) for which the event creations failed to an admin.
Thanks in advance for your help!







platform-event






share|improve this question







New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 26 at 14:16









DirkDirk

412




412




New contributor




Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dirk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 5





    This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

    – Derek F
    Apr 26 at 14:51












  • 5





    This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

    – Derek F
    Apr 26 at 14:51







5




5





This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

– Derek F
Apr 26 at 14:51





This is a very well asked question, even moreso for a first question. Hope you feel like sticking around and contributing more questions (and answers) in the future!

– Derek F
Apr 26 at 14:51










1 Answer
1






active

oldest

votes


















6















What could cause a creation of a platform event to fail?




You can actually find this on Platform Event Error Status Codes which lists down the reasons for the failures. And it seems there are primarily only two of such scenarios where it could fail.




LIMIT_EXCEEDED



The number of published platform event messages exceeded the hourly publishing limit or the test limit for event messages published from an Apex test context.



PLATFORM_EVENT_PUBLISHING_UNAVAILABLE



Publishing platform event messages failed due to a service being temporarily unavailable. Try again later.



...



The status code can be returned in Apex in the Database.SaveResult in the Database.Error object





For your other question:




I want an exception or at least I want to know which events failed to be created and why




The Event.publish() does return if a publish failed:




The result of publishing the given event. Database.SaveResult contains information about whether the operation was successful and the errors encountered. .... If isSuccess() returns false, the event publish operation resulted in errors, which are returned in the Database.Error object.




This is also mentioned in the status code docs as referred above.




As for handling the exceptions, I think as long as you do not really hit the aforementioned limits or platform issues, you should be fine. But still if you want to, you do have a way to know if the publishing failed or succeeded.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Dirk is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260227%2fwhat-causes-platform-events-to-fail-to-be-published-and-should-i-cater-for-faile%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6















    What could cause a creation of a platform event to fail?




    You can actually find this on Platform Event Error Status Codes which lists down the reasons for the failures. And it seems there are primarily only two of such scenarios where it could fail.




    LIMIT_EXCEEDED



    The number of published platform event messages exceeded the hourly publishing limit or the test limit for event messages published from an Apex test context.



    PLATFORM_EVENT_PUBLISHING_UNAVAILABLE



    Publishing platform event messages failed due to a service being temporarily unavailable. Try again later.



    ...



    The status code can be returned in Apex in the Database.SaveResult in the Database.Error object





    For your other question:




    I want an exception or at least I want to know which events failed to be created and why




    The Event.publish() does return if a publish failed:




    The result of publishing the given event. Database.SaveResult contains information about whether the operation was successful and the errors encountered. .... If isSuccess() returns false, the event publish operation resulted in errors, which are returned in the Database.Error object.




    This is also mentioned in the status code docs as referred above.




    As for handling the exceptions, I think as long as you do not really hit the aforementioned limits or platform issues, you should be fine. But still if you want to, you do have a way to know if the publishing failed or succeeded.






    share|improve this answer



























      6















      What could cause a creation of a platform event to fail?




      You can actually find this on Platform Event Error Status Codes which lists down the reasons for the failures. And it seems there are primarily only two of such scenarios where it could fail.




      LIMIT_EXCEEDED



      The number of published platform event messages exceeded the hourly publishing limit or the test limit for event messages published from an Apex test context.



      PLATFORM_EVENT_PUBLISHING_UNAVAILABLE



      Publishing platform event messages failed due to a service being temporarily unavailable. Try again later.



      ...



      The status code can be returned in Apex in the Database.SaveResult in the Database.Error object





      For your other question:




      I want an exception or at least I want to know which events failed to be created and why




      The Event.publish() does return if a publish failed:




      The result of publishing the given event. Database.SaveResult contains information about whether the operation was successful and the errors encountered. .... If isSuccess() returns false, the event publish operation resulted in errors, which are returned in the Database.Error object.




      This is also mentioned in the status code docs as referred above.




      As for handling the exceptions, I think as long as you do not really hit the aforementioned limits or platform issues, you should be fine. But still if you want to, you do have a way to know if the publishing failed or succeeded.






      share|improve this answer

























        6












        6








        6








        What could cause a creation of a platform event to fail?




        You can actually find this on Platform Event Error Status Codes which lists down the reasons for the failures. And it seems there are primarily only two of such scenarios where it could fail.




        LIMIT_EXCEEDED



        The number of published platform event messages exceeded the hourly publishing limit or the test limit for event messages published from an Apex test context.



        PLATFORM_EVENT_PUBLISHING_UNAVAILABLE



        Publishing platform event messages failed due to a service being temporarily unavailable. Try again later.



        ...



        The status code can be returned in Apex in the Database.SaveResult in the Database.Error object





        For your other question:




        I want an exception or at least I want to know which events failed to be created and why




        The Event.publish() does return if a publish failed:




        The result of publishing the given event. Database.SaveResult contains information about whether the operation was successful and the errors encountered. .... If isSuccess() returns false, the event publish operation resulted in errors, which are returned in the Database.Error object.




        This is also mentioned in the status code docs as referred above.




        As for handling the exceptions, I think as long as you do not really hit the aforementioned limits or platform issues, you should be fine. But still if you want to, you do have a way to know if the publishing failed or succeeded.






        share|improve this answer














        What could cause a creation of a platform event to fail?




        You can actually find this on Platform Event Error Status Codes which lists down the reasons for the failures. And it seems there are primarily only two of such scenarios where it could fail.




        LIMIT_EXCEEDED



        The number of published platform event messages exceeded the hourly publishing limit or the test limit for event messages published from an Apex test context.



        PLATFORM_EVENT_PUBLISHING_UNAVAILABLE



        Publishing platform event messages failed due to a service being temporarily unavailable. Try again later.



        ...



        The status code can be returned in Apex in the Database.SaveResult in the Database.Error object





        For your other question:




        I want an exception or at least I want to know which events failed to be created and why




        The Event.publish() does return if a publish failed:




        The result of publishing the given event. Database.SaveResult contains information about whether the operation was successful and the errors encountered. .... If isSuccess() returns false, the event publish operation resulted in errors, which are returned in the Database.Error object.




        This is also mentioned in the status code docs as referred above.




        As for handling the exceptions, I think as long as you do not really hit the aforementioned limits or platform issues, you should be fine. But still if you want to, you do have a way to know if the publishing failed or succeeded.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 26 at 14:28









        Jayant DasJayant Das

        19.5k21331




        19.5k21331




















            Dirk is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Dirk is a new contributor. Be nice, and check out our Code of Conduct.












            Dirk is a new contributor. Be nice, and check out our Code of Conduct.











            Dirk is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260227%2fwhat-causes-platform-events-to-fail-to-be-published-and-should-i-cater-for-faile%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form