5

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.

2
  • Are you thinking about this in the context of a UI session or in an always-on capacity?
    – David Reed
    Commented Feb 15, 2019 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. Commented Feb 15, 2019 at 17:43

3 Answers 3

4

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.

1
  • More than a year later (I'm always late to the party...). Does this seem like something Salesforce Evergreen (once it comes out) be able to handle? Also, if the external EB does not support Bayeaux - wouldn't it be possible to use 2 different protocols (one for each) and have the middleware (ie: Heroku, AWS, Azure) act as a broker between them? Commented Mar 26, 2020 at 2:14
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.

1
  • 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. Commented Feb 15, 2019 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.

1
  • One of SF architects warned that might overwhelm the APIs but they might be referring to marketing cloud. Was this an issue for you? Or is it just a licensing issue? Commented Apr 24, 2020 at 22:30

You must log in to answer this question.

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