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;
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
New contributor
add a comment |
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
New contributor
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
add a comment |
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
New contributor
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
platform-event
New contributor
New contributor
New contributor
asked Apr 26 at 14:16
DirkDirk
412
412
New contributor
New contributor
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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. .... IfisSuccess()
returnsfalse
, the event publish operation resulted in errors, which are returned in theDatabase.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.
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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. .... IfisSuccess()
returnsfalse
, the event publish operation resulted in errors, which are returned in theDatabase.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.
add a comment |
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. .... IfisSuccess()
returnsfalse
, the event publish operation resulted in errors, which are returned in theDatabase.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.
add a comment |
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. .... IfisSuccess()
returnsfalse
, the event publish operation resulted in errors, which are returned in theDatabase.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.
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. .... IfisSuccess()
returnsfalse
, the event publish operation resulted in errors, which are returned in theDatabase.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.
answered Apr 26 at 14:28
Jayant DasJayant Das
19.5k21331
19.5k21331
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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