Salesforce Developer User Group, Oslo, Norway - Salesforce PubSub API and gRPC.pptx
kennethsorensen3
177 views
22 slides
Sep 26, 2024
Slide 1 of 22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
About This Presentation
A short intro to gRPC, HTTP/2, Salesforce Pub/Suv API and Apache Avro.
Size: 205.66 MB
Language: en
Added: Sep 26, 2024
Slides: 22 pages
Slide Content
Developer User Group, Oslo, Norway SF. Pub/Sub API and gRPC Kenneth Sørensen [email protected] @kensor81
Kenneth Sørensen Tech Lead SaaS Development @ NAV I am a Salesforce Certified Application Architect with over a decade of IT experience, specializing in Salesforce development and integration. Currently leading NAV's Salesforce Platform Team – Team Platforce. I also contribute to the Salesforce Developer User Group in Oslo, focusing on practical implementations and community learning. Passionate about cloud innovation, I aim to design scalable solutions that improve internal processes and customer experiences.
Introduction to gRPC and Salesforce Pub/Sub API
What is gRPC ? Key Points : gRPC is a modern, high-performance Remote Procedure Call (RPC) framework created by Google. It uses Protocol Buffers ( protobuf ) to serialize data, making it efficient in terms of speed and bandwidth usage. Supports multiple languages and platforms, making it highly versatile.
HTTP/2 in gRPC : Enhancing Real-Time Communication What is HTTP/2? A major upgrade over HTTP/1.1, designed for faster, more efficient communication. Key improvements: multiplexing, binary protocol, header compression, server push, and stream prioritization.
HTTP/2 in gRPC : Enhancing Real-Time Communication How HTTP/2 Enhances gRPC : Multiplexing : Multiple RPC calls over a single connection without delays. Binary Protocol : Reduces overhead and speeds up message parsing. Bi-Directional Streaming : Enables real-time, continuous communication between client and server. Low-Latency Communication : Ideal for real-time applications like microservices and live streaming.
HTTP/2 in gRPC : Enhancing Real-Time Communication Benefits for gRPC : Concurrency : Multiple streams on a single connection improve scalability. Real-Time Data : Enables fast, bidirectional communication for real-time interactions. Efficiency : Reduces resource usage and increases speed for distributed systems.
Salesforce Pub/Sub API Overview Key Capabilities : Salesforce Pub/Sub API facilitates the publishing and subscribing to platform events, ensuring real-time data distribution across Salesforce and other services. Supports scalable, high-volume event processing with millions of events per second. Built using gRPC for highly efficient communication.
Apache Avro in Salesforce Pub/Sub API What is Apache Avro? A schema-based serialization system used for efficient data exchange in distributed systems.
Apache Avro in Salesforce Pub/Sub API Why Avro? Schema-Based Serialization : Uses schemas to ensure consistent structure across different platforms. Compact Data Encoding : Encodes data in binary format, reducing message size and increasing performance. Schema Evolution : Supports backward compatibility, allowing changes to event structures without breaking older versions. Interoperability : Language-agnostic, making it ideal for communication between systems in different programming languages.
Apache Avro in Salesforce Pub/Sub API Avro in Salesforce Pub/Sub API : Used to serialize platform event data into an efficient binary format. Ensures real-time, high-performance transmission of events, allowing Salesforce to manage large volumes of data. Provides flexibility through schema evolution, ensuring systems remain compatible as event definitions change.
Benefits of Integrating gRPC with SF Pub/Sub API Key Benefits : High Throughput & Low Latency : Using gRPC’s efficient serialization, Salesforce Pub/Sub API can handle real-time, large-scale data processing. Cross-Platform Compatibility : gRPC’s support for multiple languages allows integration with backend systems across various environments. Real-Time Synchronization : Bidirectional streaming in gRPC complements Salesforce’s event-driven architecture.
Exploring gRPC : Project Setup Key Files : package.json : Manages project dependencies. todo.proto : Defines the structure of the gRPC service. server.js : Implements the gRPC server that handles to-do operations. client.js : Implements the client that sends requests to the server.
Define the Proto File ( todo.proto ) Key Components : Service Definition : Defines the methods ( createTodo , readTodos , readTodosStream ) that will be exposed by the gRPC service. Message Definition : Defines the structure of TodoItem that will be exchanged between the client and server.
gRPC Server Implementation ( server.js ) Key Code : createTodo : Adds a new to-do item. readTodos : Returns all to-do items. readTodosStream : Streams to-do items one by one to the client(server).
Salesforce Pub/Sub API: Java Quick Start Overview : Define Platform Events : Define events like Order_Event__e in Salesforce to publish and subscribe to them. Build Java Client : Use gRPC to implement a Java client that subscribes to platform events. Use PublishStream and Subscribe RPC Methods : Publish platform events and receive them in real-time.
Running the Java Pub/Sub API Example Steps : Install Java dependencies and build the project using Maven. Run the server to handle event subscriptions and publish events. Execute the client to publish and subscribe to events in real time.
Conclusion Key Points : gRPC is a robust framework for building high-performance, real-time distributed applications. Salesforce Pub/Sub API leverages gRPC for efficient, scalable event-driven architectures and real-time event streaming. Apache Avro plays a crucial role in the Salesforce Pub/Sub API, enabling compact, efficient data serialization with support for schema evolution. Together, these technologies provide powerful tools for building scalable and interoperable systems, especially in large enterprises with complex data flows.
Some useful links gRPC Node example : https://youtu.be/Yw4rkaTc0f8?si=-fH94MYakerKDCGV&t=1185 SF Pub/Sub API example : https://github.com/forcedotcom/pub-sub-api SF Pub Sub API: https://developer.salesforce.com/docs/platform/pub-sub-api/overview Apache Avro : https://avro.apache.org/ gRPC : https://grpc.io/ Trailhead - Pub/Sub API Basics: https://trailhead.salesforce.com/content/learn/modules/pub-sub-api-basics