Subscribe to a Topic

 

To subscribe to a topic, add the Subscribe topic listener (subscribe-topic-listener) or Replay topic listener (replay-topic-listener) as an input source for your flow from mule palette

The input source acts as an inbound endpoint. Every time the subscription receives an event, the input source executes the rest of the flow in your Mule app.

Prerequisites:

  • Installing salesforce connector(by login into anypoint exchange from studio you can install the salesfoce conenctor)
  • Salesforce developer account
  • Security token
  • Consumer key and secret(If you are using the Salesforce connector to access an OAuth API, you also need a consumer key and secret)

Create project in anypoint studio

Drag and drop Salesforce Subscribe Topic Operation from mule palette

Subscribe Topic

 

Configure the connection details for salesforce and use the Basic Username and Password connection(Username,Password,Securitytoken),you can also use other connections as well to do the configuration like Oauth UserName and Password etc

Subscribe Topic

 

Configure Topic name as AccountUpdate created in last tutorial(Publish Topic)

Subscribe Topic

Transform the message for the notifications received from the topic

%dw 2.0
output application/json
---
payload

Deploy the application and test

For testing purpose create a new account as TestDemo in Salesforce

 

Notification Received from Topic as shown in logs below

INFO 2020-05-04 14:03:19,082 [[MuleRuntime].io.06: [subscribetopic].io@org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource.lambda$null$9:329 @76dd4add] [event: ] org.mule.extension.salesforce.internal.service.streaming.StreamingClient: BayeuxClient starting.

INFO 2020-05-04 14:03:21,704 [HttpClient@694460cb-110] [event: ] org.mule.extension.salesforce.internal.service.streaming.StreamingClient: Handshake successful, subscribing.

INFO 2020-05-04 14:03:22,384 [[MuleRuntime].io.06: [subscribetopic].io@org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource.lambda$null$9:329 @76dd4add] [event: ] org.mule.extension.salesforce.internal.service.streaming.StreamingClient: Subscribing to: /topic/AccountUpdate from replyId: -1

INFO 2020-05-04 14:03:24,633 [HttpClient@694460cb-104] [event: ] org.mule.extension.salesforce.internal.service.streaming.StreamingClient: Successfully subscribed to /topic/AccountUpdate

INFO 2020-05-04 14:07:54,522 [[MuleRuntime].cpuIntensive.01: [subscribetopic].subscribetopicFlow.CPU_INTENSIVE @5f3571ea] [event: 8c1e1b10-8de2-11ea-96d4-040e3cd1eac7] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Payload Received From Topic: {

“Id”: “0012w00000BFeJsAAL”,

“Name”: “TestDemo”

}

 

Sample application: subscribetopic sample application

 

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments