Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Streaming is a method used to transfer data over a network as a continuous flow. One of its main benefits is that it allows the data recipients to use it in an almost immediate mannerreal time, without having to wait until the complete data set has arrived at been uploaded on their computers.

What is the Salesforce Streaming API

Salesforce has a set of data APIs that can be used to manipulate the app’s App’s data. Among them, the Streaming API is used to set notifications triggered by data changes. The notifications are sent from a server to a client.

The Salesforce Streaming API follows the Publish – Subscribe model. In it, users subscribe to available channels that broadcast specific data changes. These data changes are defined by SOQL queries. For example, a channel can notify its users about changes in account’s emailsAccount’s Emails.

The main advantage of this model is that it eliminates pooling and therefore, and it is therefore useful for communicating very frequent changes , - practically producing real time integration.

...

Main Characteristics of the Salesforce Streaming API

This Saleforce Salesforce API has many important characteristics that define its behavior. Among them:

  1. Communication type: the API is based on asynchronous communication.
  2. Bayeux Protocol: the API uses this protocol in the transmission of to transmit asynchronous messages.
  3. CometD: the API uses this scalable event routing bus for message transmission. It is based on Ajax communication and the Bayeux protocol. The method opens a single persistent connection from the client to the server. Events are then incrementally handled and interpreted on the client’s Client’s side, every time a new event arrives.
  4. Long polling or Comet programming: this method emulates an information push from server to client. As it waits until there is some data to be sent, it doesn’t send no-data notifications.

...

It is within the context of the Salesforce Streaming API that, DBSync developed a connector that can be used specifically for real time integration. The connector is known as Salesforce Streaming Connector.

...

In this example we will connect Salesforce table Accounts to a MySQL table Accounts. The steps are:

  1. Create a new project.
  2. Create a Salesforce Streaming Connector and a Database Connector.
  3. Create a new process.
  4. Create a new workflow.
  5. Create a new trigger, rule and map.
  6. Create a schedule.
  7. Run the process.

...

As we mentioned earlier, we want to create a process that runs as continuously as possible. However, DBSync cannot detect if the process has stopped for any reason, ; and thus, it cannot restart it automatically.

In order to solve this problem, we need to set up the schedule at every one minute apartinterval. The cron expression for this is “0/1 0/1 1/1 ?*”. Alternatively, we can simply select minutes and specify “1”.

...

Figure 2

Create a Trigger

As in our example we are transferring data from Salesforce to MySQL, we need to create a trigger that contains a query. This query must include the id ID of the Salesforce table , - in our case Accounts, and the . The query must not include joins or aggregate functions. Besides, the WHERE clause must not include lookup fields.

...

When we create a new rule, we must make sure to map the Id ID from Salesforce to the MySQL table’s idID.

Figure 4

Seeing the Results

...

DBSync’s Salesforce Streaming Connector allows us to link Salesforce to another application in practically almost real time.

However, there are a few aspects to consider - namely, the setting up of the schedule with a repeating frequency of one minute, ; the limitations on the trigger’s query; and, and the mapping of idsIDs.