Salesforce platform event duplicate events with ComeTd Client

920 views Asked by At

I have built Salesforce platform event client using CometD java and It's similar to example EMP-Connector provided by forcedotcom.

I installed this client on OpenShift cloud and my app is running with 2 pods. Problem I am facing is that since there are two pods and each are running the same docker image thus both are getting the same of event. That means duplication event. Per my understanding, Salesforce platform event should behave like Kafka subscriber.

I am unable to find a solution about how to avoid getting the same copy of events. Any suggestions here would be the great help.

Note: As of now I am able to create client side solution which drop duplicate copy of event. which is not an optimal solution. I have to run my app atleast with 2 pods. That's limit I have on my cloud.

1

There are 1 answers

0
identigral On BEST ANSWER

This is expected / by design. In CometD, when a message is published on a broadcast channel all subscribers listening on this channel will receive a copy of this message. The broadcast channel behaves like a messaging topic where one sender wants to send the same info to multiple recipients. There are other types of channels in CometD with different semantics. The broadcast channel and one-to-many message semantics is what you get with platform events available via CometD in Salesforce.

In your case it sounds like you have multiple subscribers, thus what you're seeing is expected. You can deduplicate the message stream on the client side as you have done or you can change your architecture so that you have a single subscription.