3

I'll confess up front that my knowledge of event architecture is limited:

Can the cometd library that we can use to listen for Streaming API and Platform Events also be used to listen to external (i.e. non-Salesforce) event buses?

We're hoping to make Salesforce a subscriber to replace polling integrations through the REST API.

  • Are you thinking about this in the context of a UI session or in an always-on capacity? – David Reed Feb 15 at 15:36
  • An always-on capability so that instead of having new data pushed to a Salesforce endpoint from an external system, Salesforce is able to listen for changes and pick up relevant ones from an event bus to injest and process the data. – AlwaysThinkin Feb 15 at 17:43
2

If the external bus supports the Bayeux protocol, then you could use the same CometD library and code to subscribe to both the Salesforce bus and the external bus. The solution in this case would be running off-platform (ie: Heroku, Azure, AWS) because there isn't an on-platform option to subscribe to an event bus outside of Salesforce. The subscriber would republish the event as a Salesforce platform event using the REST, SOAP, or Bulk API. While this is theoretically possible, most buses use different protocols (STOMP, MQTT, AMQP, WebSockets, direct Kafka, etc).

TLDR: technically possible, although not likely.

4

I'm assuming you want this to be something running in Apex and not something that relies on Visualforce or Lightning Component.

If you want to have Salesforce subscribe to an event, you will need to publish to a Salesforce Platform Event. You can then write an Apex trigger in that event. There isn't a way to have cometd trigger Apex directly. See https://trailhead.salesforce.com/en/content/learn/modules/platform_events_basics/platform_events_architecture.

You can subscribe to generic events in a Visualforce page or a Lightning Component, but that would require someone to be signed in and have the page open.

  • Ah, so the cometd utility that I use to check Streaming events only works because it's embedded in a Visualforce page, that makes sense now. – AlwaysThinkin Feb 15 at 17:52
4

As of now, we do not have a way to subscribe to the external event bus which is always on. You have to use a middleware to subscribe to external event bus and then push same into SF event bus.

We use Mulesoft Anypoint platform as a middleware.

Anypoint platform reads from External event bus using Amazon SQS connector , transforms data to SF Data model form and publishes into Salesforce Event Bus.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.