Integration Cloud 7.0.0 | Accounts, Operations, Listeners | Listeners | Creating and updating listeners
 
Creating and updating listeners
*To add a listener
1. From the Integration Cloud navigation bar, click Projects > <Select a Project > Applications > Predefined Applications.
Note:
You must have the required project permissions under Settings > Project Permissions to create, update, and delete listeners. Further, to create a Listener and also invoke the associated Integration when events are received, you must have the Listeners Create permission and the Integration Execute permission.
2. Select a predefined Application and click Listeners.
To use an Application, you are required to agree to the summary of terms. Click I agree to use the Application. Click I do not agree if you disagree with the summary of terms and do not want to use the Application. Click Cancel to go back to the Applications page.
The Listeners page appears for the selected Application.
Note:
Listeners option appears only for Applications that have streaming API capability.
3. On the Listeners page, click Add New Listener to add a listener or click Edit to update a listener.
4. On the Configure the Listener page, complete the following fields. Required fields are marked with an asterisk on the screen.
Field
Description
Save As
Provide a valid name for the listener. Names can contain alphanumeric characters, underscores (_), and hyphens (-). The name must not be null and cannot be an empty string.
Description
Provide a description for the listener.
Streaming API Endpoint URL
Specify the endpoint of the streaming provider. When configuring a Salesforce streaming endpoint, specify the URL in the following format: https://<Salesforce_Instance>/cometd/<Salesforce API version>
Example: https://ap5.salesforce.com/cometd/44.0
Select replay option
The Integration Cloud listener for Salesforce can subscribe and listen to Salesforce events. This allows the Integration Cloud listener to establish a persistent connection with Salesforce. This connection remains open while transmitting the events until either side closes the connection. Through this established connection, events are streamed to the listener. If the connection is lost due to a network failure or any other reason, you can retrieve the standard-volume events that are within Salesforce's 24-hour retention window. You can retrieve Salesforce events only if you are using Salesforce v37.0 or later versions.
Each Salesforce event is assigned an opaque ID which is unique for each event. This ID is contained in the replayId field of the event object. The replayId field value which is populated by Salesforce when the event is delivered to subscribers, refers to the position of the event in the event stream. For consecutive events, replayId values may have a break between them, for example, the event with ID 110 may follow the event with ID 101.
Example of an event object that Salesforce sends to its subscribed clients
{
"clientId":"a1ps4wpe52qytvcvbsko09tapc",
"data":{
"event":{
"createdDate":"2016-03-29T19:05:28.334Z",
"replayId":55
},
"payload":"This is a message."
},
"channel":"/u/TestStreaming"
}
To replay events, Salesforce provides a way to configure the replayId while subscribing to a particular channel. You can replay the events by specifying the replay option and can use it on a resubscription, to retrieve events that are within the retention window.
*New - Receive new events that are broadcast after the client subscribes and replay only the new events from the time the listener is enabled.
*All - Receive all events including past events that are within the retention window including new events. Replay all the events for the last 24 hours.
Select account
Select an account to connect to the Application. The streaming functionality will leverage the existing authentication, timeouts, truststore, keystore, and host name verification configurations from the referenced Account selected in the Select account drop-down list box.
Select subscription
Select a channel from the list of available subscription channels, that is, select the subscriber you want the listener to connect.
5. Click Next.
The Parameters and Headers page appears.
6. In the Parameters section, Integration Cloud displays the pre-configured parameters for the selected subscription.
a. Review the details about the parameters. Integration Cloud displays the parameter name and description, the data type used to represent the kind of information the parameter can hold, and the parameterization type for the subscription request.
b. To specify the default value for the parameter, select the pre-configured parameter and click Edit. In the Parameter Properties dialog box, type the default value. For example, for Salesforce, type the Topic Name. The Active option includes the parameter as part of the subscription request.
7. In the Headers section, Integration Cloud displays the pre-configured HTTP transport headers for the selected subscription.
a. To specify a value for a pre-configured header variable, click Edit and then in the Header Properties dialog box, type the new default value.
b. To add a header, click Add Header. Type a name for the header, select the Active check box to include the header as part of the subscription request, and provide a default value.
c. To delete a header that you have added, select the header and click Delete.
Note:
You cannot delete required headers.
8. Click Next.
The Event page appears.
9. On the Event page, specify the event action configuration for the listener subscriber. You can invoke an Integration based on your configuration.
a. In the Integration Name field, select the Integration that will be invoked when the events are received. In the Run As User field, select the Integration Cloud user you want Integration Cloud to use when running the Integration. Integration Cloud runs the Integration as if the user you specify is the authenticated user that invoked the Integration. If the Integration is governed by an Access Control List (ACL), ensure that you specify a user that is allowed to invoke the Integration.
Note:
You must manually run the Integration before you map that Integration to the listener, else the listener will not execute the mapped Integration.
10. Click Next, review the Summary details, and then click Finish to create the listener.
The new listener appears on the Listeners page.
11. To enable the new listener, move the slider under the Status column.
The listener will be enabled after a short delay. Once the listener is enabled, connection with the streaming API is established, and incoming events will be processed whenever the streaming provider triggers the events. As an example, for Salesforce CRM version 44, say you have created a topic using the following sample query.
Sample Query
PushTopic testCvent = new PushTopic();
testCvent.ApiVersion = 42.0;
testCvent.Name = 'TestContact';
testCvent.Description = 'All records for the Contact object';
testCvent.Query = 'SELECT Id, Email, Phone, FirstName, LastName, Title, Salutation
FROM Contact';
insert testCvent;
System.debug('Created new PushTopic: '+ testCvent.Id);
After that you have subscribed to that topic by creating a listener in Integration Cloud. Now whenever the Contact object is modified in Salesforce, the Integration Cloud listener is notified. To use the streaming data as an input to an Integration, ensure that you create a JSON document type that has the same fields inside sobject as that of the query parameters of the topic.
Sample Document
{
"data":{
"event":{
"createdDate":"",
"replayId":"",
"type":""
},
"sobject":{
"Email":"",
"Phone":"",
"FirstName":"",
"Title":"",
"LastName":"",
"Id":"",
"Salutation":"",
}
},
"channel":"/topic/TestContact2"
}
Note:
If a listener L1 is using an Integration IN1 and if IN1 uses an Operation OP1 which triggers L1 through a Salesforce Topic, then whenever OP1 is run, L1 will be triggered. L1 will again execute IN1 and IN1 will again execute OP1, thereby creating Integration execution loops. Therefore ensure that loops are not created in an Integration, which is mapped to a listener.