3

I have requirement to subscribe salesforce platform events in external systems(adobeConnect) and display event notifications.

For that I have a trigger to publishing the platform events and I wrote a REST api class to subscribe events.

Trigger :

trigger MeetingTrigger on AdobeMeeting__c (after update) {
    List<lightningdeve__Meeting__e> OrdEvents = New List<lightningdeve__Meeting__e>();
    for (AdobeMeeting__c o: Trigger.new) {
        if(o.lightningdeve__Status__c   == 'NotStarted'){
           OrdEvents.add(new lightningdeve__Meeting__e( lightningdeve__Type__c=o.lightningdeve__Status__c));
        }
    }
    if(OrdEvents.size()>0) 
    EventBus.publish(OrdEvents); 

REST api to subscribe platform event

public class SubscribePlatformEventsChannel {

 public static HttpResponse getEventInformation() {

    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setEndpoint(System.URL.getOrgDomainUrl().toExternalForm() + '/event/lightningdeve__Meeting__e');
    request.setMethod('GET');
    HttpResponse response = http.send(request);
    System.debug('Response:::'+response.getBody());
    return response;
  }

This is the right way to subscribe platform events ?

or suggest any other possibilies to suitable to my requirement.

Thanks

2

1 Answer 1

2

The external system should listen for platform events using CometD (or you can use the EMP Connector: an open-source, community-supported tool that implements all the details of connecting to CometD and listening on a channel).

Salesforce has a guide on how to do this.

Salesforce sends platform events to CometD clients sequentially in the order they’re received. The order of event notifications is based on the replay ID of events.

The process of subscribing to platform event notifications through CometD is similar to subscribing to PushTopics or generic events. The only difference is the channel name. The platform event channel name is case-sensitive and is in the following format.

Source: Subscribe to Platform Event Notifications with CometD.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .