About Me

My photo
PLANO, Texas, United States
Showing posts with label #Platform-event. Show all posts
Showing posts with label #Platform-event. Show all posts

Thursday, September 17, 2020

Platform Event

 What is Platform Event?

  • Platform Event is based on Event-Driven Architecture enable apps to communicate inside and outside of Salesforce.
  • Platform events are based on the publish/subscribe model and work directly with a message bus that handles the queue of incoming events and processes listening for them. This is built-in real-time integration patterns in the Salesforce Platform which help to reduce point-to-point integration
What is Event-Driven Software Architecture?
An event-driven (or message-driven) software architecture consists of event producers, event consumers, and channels.
  • Event: A change in state that is meaningful in a business process.
  • Event message / Notification: A message that contains data about the event.
  • Event producer: The publisher of an event message over a channel.
  • Channel: A conduit in which an event producer transmits a message. Event consumers subscribe to the channel to receive messages. Also referred to as event bus in Salesforce.
  • Event consumer: A subscriber to a channel that receives messages from the channel
Characteristics of Platform Event
  •  SObject like Salesforce Entity
    • Suffixed with __e
    •  Only Checkbox, Date, Date/Time, Number, Text, and Text Area field available.
  • Pub / Sub based communication
    • No Polling required. Whenever an event occurs, the consumer will get notified  

Difference between SObject and Platform Events-

  • Platform event only support insert whereas sObject support all DML
  • You can not query Platform events through SOQL or SOSL
  • You can not use Platform in reports, list views, and search. Platform events don’t have an associated tab
  • Published platform events can’t be rolled back.
  • Only after insert Triggers Are Supported
Publishing / Subscribing Platform Events-













Publish Platform Events

We can publish platform events in 3 ways:
  1. Publish Events Messaging using APEX- User EventBus.publish() method to publish
  2. Publish Events Messaging using Declarative tools 
  3. Publish Events Messaging using Salesforce API from external app

Subscribing Platform Events :

We can subscribe to the platform events with the following ways :
  1. Apex Trigger-Write an “after insert” Apex trigger on the event object to subscribe to incoming events.
  2. Subscribe to platform event notification in Lightning components
    1. Lightning web components :  Use the empApi methods in your Lightning web component, import the methods from the lightning/empApi module as follows

      import { subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled }
          from 'lightning/empApi';
    2. Subscibe in an Aura Component : Use the empApi methods in your Aura component, add the lightning:empApi component inside your custom component and assign an aura:id attribute to it
      <lightning:empApi aura:id="empApi"/>
  3. In an external app, you subscribe to events using CometD as well.
  4. Flow and process builder. Check this post.
To know about other integration API at a glance, pls Click here

Wednesday, January 13, 2016

Salsforce API

API stands for Application Programming Interface. With the help of API, we can connect two or more applications altogether. 

To understand the concept of API, let's consider the example of a restaurant. If you go there, you will get a Menu list, and there will be a separate kitchen. You just select the item from the menu list and the waiter will take the order and send it to the chef in the kitchen and once the order is ready, he will deliver to you.  You know need to worry about how the order will come. You just order and you get it from the waiter. Here waiter is working as an API.

There are the following APIs in the Salesforce:

REST API

  • Force.com REST API lets you integrate with the force.com applications using simple HTTP methods.
  • The request/response would be in the form of xml or JSON.
  • Useful in light weighted application like mobile application
  • Click for more detail

SOAP API

  • SOAP API works on SOAP (WSDL) protocol. 
  • The request/response would be in the form of xml.
  • We can use SOAP API to integrate Salesforce with your organization’s ERP and finance systems.
  • Click for more detail

Tooling API

  • As the name itself suggests, use tooling API to build custom development tools for Force.com applications.
  • You can get the code coverage information with the help of Tooling API.

Streaming API

  • Use Streaming API to receive notifications for changes to data that match a SOQL query that you define.
  • Streaming API is useful when you want notifications to be pushed from the server to the client.
  • Streaming API enables you to reduce the number of API calls and improve performance.
  • Click for more detail

Chatter REST API

  • Access Chatter feeds and social data such as users, groups, followers, and files using REST.
  • Click for more detail

Bulk API

  • Bulk API is based on REST principles and is optimized for loading or deleting large sets of data.
  • You can use it to query, insert, update, upsert, or delete many records asynchronously by submitting batches. Salesforce processes batches in the background.
  • SOAP API, in contrast, is optimized for real-time client applications that update a few records at a time. SOAP API can be used for processing many records, but when the data sets contain hundreds of thousands of records, SOAP API is less practical. Bulk API is designed to make it simple to process data from a few thousand to millions of records.
  • The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. Using Data Loader avoids the need to write your own client application.
  • Click for more details

Metadata API

  • Use Metadata API to retrieve, deploy, create, update, or delete customization for your organization. 
  • The most common use is to migrate changes from a sandbox or testing organization to your production environment. 
  • Metadata API is intended for managing customization and for building tools that can manage the metadata model, not the data itself. Like The Force.com Migration Tool, Force.com IDE
  • Click for more detail

Apex REST API

Apex SOAP API
  • Use Apex SOAP API when you want to expose Apex methods as SOAP Web service APIs so that external applications can access your code through SOAP.
  • Click for more detail
To know more about the security aspect of integration, pls Click here