1

I need to use filtered subscription using lightning:empAPI for Push Topic notifications. But it does not work with Id filter after records page refresh (F5) whereas when it subscribes on the first place the notifications are coming in.
Does it mean that only one active filtered subscription has to exist for the record and user session? If so how can I unsubscribe prior the component is reloaded and new subscription is initiated during refresh (F5).

<aura:attribute name="channel" type="String" default="{!'/topic/QuoteProcessing?Id=' + v.recordId}"/>
<!--<aura:attribute name="channel" type="String" default="/topic/QuoteProcessing"/>-->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" closable="false"/>

// doInit just executes helper.subscribe
helper.subscribe(component, event);

// helper.subscribe
subscribe : function(component, event) {
        const empApi = component.find('empApi');
        const channel = component.get('v.channel');
        const replayId = -1;
        //var Qchannel = '/topic/QuoteProcessing?Id='+component.get('v.recordId');
        // Subscribe to an event
        //console.log('Qchannel '+Qchannel);
        empApi.subscribe(channel, replayId, $A.getCallback(eventReceived => {
            console.log('Received event ', JSON.stringify(eventReceived));  
            $A.get('e.force:refreshView').fire();  
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
            mode : "dismissable",
                message : "Processing  - "+eventReceived.data.sobject.ProcessingStatus__c,
                type : "info",
                duration : 8000
            });
            toastEvent.fire();   
        }))
        .then(subscription => {
            console.log('Subscribed to channel ', subscription.channel);
            console.log('subscription ', JSON.stringify(subscription));
            component.set('v.subscription', subscription);
        });    
        empApi.onError($A.getCallback(error => {
            console.log('EMP API error from subscribe: '+ JSON.stringify(error));
        }));   
    }

PushTopic query contains Id and the field I am changing in SELECT clause. Subscription is established but notifications are not coming.

9
  • Push Topic query: SELECT Id, Name, ProcessingStatus__c FROM MyCustomObject
    – Andrew
    Mar 20, 2019 at 10:50
  • Andrew - this seems to be a known issue with Salesforce, refer to the question linked as duplicate for details.
    – Jayant Das
    Mar 20, 2019 at 13:58
  • Jayant - I have seen that question but I cannot comment on it with my score) So, it seems that it was posted fairly long time ago. Is there a resolution in place, was the fix deployed by Salesforce? The link to EMP connector on git does not give me any idea how to bypass the problem...
    – Andrew
    Mar 20, 2019 at 15:18
  • Let me check on that. I will comment on that question to see if it has been resolved.
    – Jayant Das
    Mar 20, 2019 at 15:33
  • Andrew - While I have commented on the answer there, I have also tweeted to see if I get a response, will keep this thread posted.
    – Jayant Das
    Mar 20, 2019 at 15:48

0

Browse other questions tagged .