4

Trying to solution for the following use case:

  • A desktop softphone
  • Salesforce Classic Visualforce Page
  • On call received on desktop softphone, pop in user's classic SF console.

Created platform Event with two custom fields, Phone__c and Employee_UID__c that the desktop softphone would call on inbound call answered:

/services/data/v53.0/sobjects/My_Call_Event__e/

Payload:

{
"Employee_UID__c":"MY ID HERE",
"Phone__c":"8885551234"
}

VFP in Console Bar:

<apex:page showHeader="false" sidebar="false">  

<apex:includeScript value="{!$Resource.cometd}"/>
<apex:includeScript value="{!$Resource.jqueryjs}"/>
<apex:includeScript value="{!$Resource.json2}"/>
<apex:includeScript value="{!$Resource.jquery_cometd}"/>
<apex:includeScript value="/soap/ajax/33.0/connection.js"/>
<apex:includeScript value="/support/console/33.0/integration.js"/>

<script>    

(function($){
    $(document).ready(function() {
        
        $.cometd.configure({
            url:  window.location.protocol+'//'+window.location.hostname+'/cometd/49.0',
            requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'},
            appendMessageTypeToURL : false
        });     
        console.log('before handshake')  
        $.cometd.websocketEnabled = false; 
        
        $.cometd.handshake();
        console.log('before addListener');  
        
        $.cometd.addListener('/meta/handshake', function(message) {
            $.cometd.subscribe('/event/My_Call_Event__e', function(message) {
                
                console.log(message.data.payload.Phone__c);

                if (message.data.Employee_UID__C == {$User.EmployeeNumber}){
                sforce.console.openPrimaryTab(null, '/apex/CallPopPage?ani=' + message.data.payload.Phone__c, true, 'Customer Search');
                }
            });   
        });
        
    });
})(jQuery)

</script>
</apex:page>

This works great, but... limits.

I should be good on the concurrent subscribers limit for being under 2000 users waiting for call.

However, there may be greater than 50k delivered events in the last 24 hours shared across all clients.

Can someone please elaborate what "event delivery" is defined as?

For example, if I have 1000 users on SF and they receive every event and 51 calls come in == 51 published platform events to 1000 waiting users won't I go past the limit?

Is this where we would need to purchase the High-Volume Platform Event Add-On Licenses? Is there some sort of filter setting on CometD I'm missing to only get events related to a field value?

Is SF not designed for this volume of event subscriptions? Do I need to consider external event solutions like AWS Event Bridge?

6

If I have 1000 users on SF and they receive every event and 51 calls come in == 51 published platform events to 1000 waiting users won't I go past the limit?

Yes the number of events delivered would reach 50K limits as the number of events delivered will be 51*1000 = 51000 (51K)

This is where if you are looking for native solution you have below options

  1. Purchase additional Licenses (High-Volume Platform Event Add-On License and Usage-Based Entitlement ) as detailed in the docs
  2. Get into a pilot program that provides ability to Filter Your Stream of Platform Events with Channels (Pilot)

The other alternative is ofcourse use a Middleware like Mulesoft to Fanout the messages using Fanout pattern to improve efficiency.

You could also use Heroku and build your own Middleware for fan-out using Node.js.

Check the blogpost I wrote lately on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.