Nav

To Work with Streaming Channels (Salesforce Connector)

Streaming channels provide notifications to subscribers that are not limited to record-based events. You can use the Salesforce Connector to work with Salesforce streaming channels.

About Channel Inbound Properties

Information that gets passed along as inbound properties:

Property Name Scope Maps to

channel

INBOUND

Channel JSON property

type

INBOUND

Type JSON property in data

createdDate

INBOUND

createdDate JSON property in data

Except for channel, every property inside event is available as an INBOUND property.

To Replay Events from a Streaming Channel

The streaming channel can replay notifications, much like topic replay.

The replay-streaming-channel acts like an inbound endpoint and it can be used as such:


          
       
1
2
3
4
5
6
<flow name="flowStreamingChannelReplay">
    <!-- INBOUND ENDPOINT -->
    <sfdc:replay-streaming-channel streamingChannel="/u/Notifications" replayId="1" replayOption="ALL"/>
    <!-- REST OF YOUR FLOW -->
    <logger level="INFO" message="Replayed events: #[payload]"/>
</flow>

If ALL or ONLY_NEW replay option is selected, then the replayId value is ignored.

To Push Events to a Streaming Channel

Salesforce offers to possiblity to push custom events to a specific streaming channel through the REST API. The user can achieve this using Workbench or using this connector.

You can use push-generic-event operation as follows:


          
       
1
2
3
4
5
6
7
8
9
<flow name="flowPushGenericEvent">
    <!-- INBOUND ENDPOINT -->
    <sfdc:push-generic-event channelId="0M6j0000000KyjBCAS">
            <sfdc:events>
            <sfdc:event payload="Notification message text"/>
        </sfdc:events>
        </sfdc:push-generic-event>
    <logger level="INFO" message="Replayed events: #[payload]"/>
</flow>

The channel ID can be retrieved from the response map of the publish-streaming-channel operation. Another way of retrieving the id of the channel is from the Salesfroce page, as follows:

  1. Log into your Developer Edition organization.

  2. Under All Tabs (+) select Streaming Channels.

If the channel ID field on the is not visible on the channel list, then:

  1. Click on Create New View.

  2. Type a name for the view in the Name input field.

  3. In the Available Fileds list, select Streaming Channel ID, and click Add.

  4. Add any other fields you want.

  5. Click Save.

Now you should see the channel ID for each streaming channel in the list.

The JSON received as response from the push event operation looks something like:


          
       
1
2
3
4
5
6
7
[
        {
        "userOnlineStatus": {
        },
        "fanoutCount": 0
        }
]

To Monitor a Batch in Salesforce

You can monitor a Bulk API batch in Salesforce.

To track the status of bulk data load jobs and their associated batches, click Your Name > Setup > Monitoring > Bulk Data Load Jobs. Click the Job ID to view the job detail page.

The job detail page includes a related list of all the batches for the job. The related list provides View Request and View Response links for each batch. If the batch is a CSV file, the links return the request or response in CSV format. If the batch is an XML file, the links return the request or response in XML format. These links are available for batches created in Salesforce API version 19.0 and later.

To Create a Streaming Channel

To create a streaming channel:

You must have the proper Streaming API permissions enabled in your organization.

  1. Log into your Developer Edition organization.

  2. Under All Tabs (+) select Streaming Channels.

  3. On the Streaming Channels tab, select New to create a new Streaming Channel.

  4. Enter /u/notifications/ExampleUserChannel in Streaming Channel Name, and an optional description.

    Your New Streaming Channel page should look something like this:

You can either use the create operation or the exclusive  publish-streaming-channel operation as follows:


         
      
1
<sfdc:publish-streaming-channel name="/u/Notifications" description="General notifications"/>

To Subscribe to a Streaming Channel

After you create a streaming channel, you can start receiving events by subscribing to the channel. The `subscribe-streaming-channel` acts like an inbound endpoint and it can be used as such:


         
      
1
2
3
4
5
6
<flow name="notificationsChannelSubscription">
        <!-- INBOUND ENDPOINT -->
        <sfdc:subscribe-streaming-channel streamingChannel="/u/TestStreaming"/>
        <!-- REST OF YOUR FLOW -->
        <logger level="INFO" message="Received an event: #[payload]"/>
</flow>

A Mule flow is divided in two. The first portion of it is usually an inbound endpoint (or an HTTP connector) and a message source. The Mule flow is an entity that receives and generates events that later are processed by the rest of the flow. The other portion is a collection of message processors that processes the messages (also known as events) that are received and generated by the inbound endpoint.

Every time our subscription to /u/TestStreaming receives an event it executes the rest of the flow. In the case of this example it prints a message to the log at INFO level.