4

I'm trying to subscribe on notifications from salesforce using Streaming API.

So I've done:

All this steps passed successfully.

...these steps are clear for testing. But I need SF to publish object changes, not REST API. So I tried the same (create topic using developer console and connect to listen changes) with configured topic via devconsole.

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'AccountChanges';
pushTopic.Query = 'SELECT Id, Name FROM Account';
pushTopic.ApiVersion = 43.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

I published new Accounts into the SF, but no notifications was received (accept handshake). Trying check topics created in SF via developer console - no topics found in Streaming Channels menu (on UI).

Any suggestions?

1

I was able to get into your situation by following exactly the same steps as you have mentioned (I must mention that you have explained it very well in your question). I think for you the issue is same as I experienced and that it's somewhere between the below mentioned steps.

  • I used java client

  • I've generated events via REST API

All this steps passed successfully.

I had forgotten to change the argument to the correct event to which I needed to subscribe in my Java client.

So, you may like to verify if you followed the example to subscribe to the Streaming Channel and that if you used /u/notifications/ExampleUserChannel in your Java client arguments, if that was changed to "PushTopic event" or not. Using the example, when you publish the event using REST API, you then are subscribing to the "Generic event", whereas later you expect to get notifications for a record change based on your "PushTopic event".

The time you create a PushTopic, you should change your Java client arguments to subscribe to your "PushTopic event", which in your case should be as:

/topic/AccountChanges

Once I made this change in my Java client, I was able to get all the events generated on the record changes.

  • I think the issue is with PushTopic notify configurations (in development console). On other hand, when I configured different Streaming Channel using UI but on UI I have no chance configure notify rules... Any way, I've no choice so I'll recheck every thing following your recommendation. – Sergii Oct 3 '18 at 8:56
  • I would think the PushTopic is getting inserted correctly and that if you subsrcibe to it, should work fine. Did you happen to verify this though? I am curious if that was the reason why you were not able to get the push topic events on record changes. – Jayant Das Oct 3 '18 at 15:34
  • Prefix /topic/ resolved this issue. Thanks. – Sergii Oct 3 '18 at 17:04

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.