0

I have implemented an API on the CloudHub platform, in a Mule application deployed on 2 Workers on Mule 4.3.0 runtime. This Mule application is listening to a Salesforce event using subscribe-channel-listener, and in Studio, I have enabled it to run on Primary Node only.

<salesforce:sfdc-config 
   name="Salesforce_Config" 
   doc:name="Salesforce Config" 
   doc:id="55f5d9c0-0fa3-4e14-a8fe-6cc6a2c3a09b" >
   <salesforce:oauth-user-pass-connection 
      username="${secure::sf.username}" 
      password="${secure::sf.password}" 
      securityToken="${secure::sf.token}" 
      consumerKey="${secure::sf.consumerKey}" 
      consumerSecret="${secure::sf.consumerSecret}" 
      tokenEndpoint="${secure::sf.tokenEndpoint}"/>
</salesforce:sfdc-config>

<salesforce:subscribe-channel-listener 
   doc:name="Subscribe channel listener" 
   doc:id="e0f47684-d458-46c9-b7c7-13399ca5af39" 
   config-ref="Salesforce_Config" 
   streamingChannel="${sf.streamingChannel}">
   <reconnect />
</salesforce:subscribe-channel-listener>

Issue: We have detected that this Mule Salesforce connector subscribes to the event 2 times, on each worker. This didn't happen just once, we re-tried again after a few minutes, and again it duplicated the even on each worker.

As we are running our APIs on CloudHub, please can someone advise me a better solution so that we never duplicate the subscribed events?

Sambit Swain
  • 131
  • 1
  • 13
  • Please share the configuration of the Salesforce connector and the usage in a flow, removing confidential information. – aled Mar 07 '22 at 13:01
  • Hi Aled, please find the configuration and listener component above. In Studio, I have marked primaryNodeOnly=true, which does not appear in the XML configuration though. – Sambit Swain Mar 07 '22 at 13:09
  • Maybe it is the default. Default values are not added to the XML by Studio UI. – aled Mar 07 '22 at 13:12

2 Answers2

1

I had faced the same issues and raised the support ticket with Mulesoft Support, and they suggested to me that for salesforce events, always use a single worker.

My application was also on CloudHub.

more inofrmation is here (this link is given by support team to me) - https://docs.mulesoft.com/salesforce-connector/10.14/salesforce-connector-processing-events

there is clearly mentioned that "If you use multiple workers when running the app in CloudHub, all of the workers receive and process the events."

Anurag Sharma
  • 780
  • 7
  • 31
  • Thanks Anurag, amending the API to run on single worker would need architectural change. In order to propose this, can I please request to share some information like - when was this solution suggested by MuleSoft support? What version of salesForce connector you used? Is it an issue only for subscribe-channel-listener? Other than duplicate subscribing the same event, did you also faced connectivity issues more often in a 2 worker environment? – Sambit Swain Mar 07 '22 at 08:24
  • I had created the support ticket last month around mid of feb and I am using 10.13.4 version of salesforce (but this issue doesnt depend on version) ,it was for subscriber and replay channel listener both,i faced the connectivity issues too but no that much, it was very rare. – Anurag Sharma Mar 07 '22 at 09:14
0

and in Studio, I have enabled it to run on Primary Node only.

If the issue is that the event is being subscribed in both workers, then that should be expected. Studio can be configured to execute simulating a single node cluster, however CloudHub doesn't deploy to a cluster, but to multiple independent nodes (workers). Hence there is no primary node in CloudHub, all nodes are equal. The solution is to deploy to a single node as Anurag Sharma mentioned.

If you need a full explanation there is a KB article (which I found after writing above answer) in MuleSoft Help Center: https://help.mulesoft.com/s/article/Why-Salesforce-Connector-set-primary-node-for-replay-channel-does-not-work-on-Cloudhub

aled
  • 21,330
  • 3
  • 27
  • 34