I'm trying to subscribe to multiple channels with CometD. I'm using the CometD static resource and syntax as per the Trailhead project: https://trailhead.salesforce.com/projects/workshop-platform-events/steps/platform-event-subscribe
When I update the subscription code in the helper to the following, the first channel subscription is not returning any events - looks like it's being overwritten by the second one.
var newSubscription = cometd.subscribe('/event/Notification__e',
function(platformEvent) {
console.log('Platform event received: '+ JSON.stringify(platformEvent));
//helper.onReceiveNotification(component, platformEvent);
});
var newSubscription2 = cometd.subscribe('/event/AnotherPlatformEvent__e',
function (message) {
console.log("Second event was heard!!");
});
// Save subscription for later
var subscriptions = component.get('v.cometdSubscriptions');
subscriptions.push(newSubscription);
subscriptions.push(newSubscription2);
component.set('v.cometdSubscriptions', subscriptions);
CometD is supposed to support Bulk Subscriptions as per https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_streaming_api_bulk.htm - I tried adding my own method into the cometd.js static resource to create the Bayeux JSON message in this format, but got lost down the JS rabbit hole.
Has anyone tried to subscribe to multiple PushTopics / Platform Events in the same Lightning Component? How did you manage it?