Streaming API Flashcards

1
Q

What is PushTopic, Event and Notification?

A

PushTopic is a record that defines a channel. Determines what event will cause a notification. Describes the data the notification will contain.

An Event is a modification of a field when creating/updating a record. An even may trigger a notification.

A Notification is the data sent as a result of an event. Notification is sent to clients that are subscribed to the associated Channel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you create a PushTopic?

A

Construct a new PushTopic object

Specify a Name

Specify a SOQL query

Specify what events should notify the client
pushTopic.NotifyForOperationCreate = true;
(CRUD and Undelete)

Optionally specify values for the PushTopic fields (pushTopic.NotifyForFields = ‘All’;)

Insert PushTopic in database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Channel Name?

A

Subscribes identify a channel using the PushTopic name.

The channel name must match the PushTopic name exactly. /topic/PositionOpen

If the PushTopic name is changed, Live subscriptions are not affected. New subscriptions must use the new channel name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to define Events that generate Notifications?

A

Using NotifyForOperationC/R/U/D/UD

Events may generate a Notification but is not guaranteed

Updates performed by the Bulk API will not generate notifications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When will an Event generate a Notification?

A

NotifyForFields specifies the fields that should be checked.

  • All - avoid using this as this will increase traffic
  • Referenced - default
  • Select
  • Where

Once a record meets the criteria specified in the NotifyForFields, it should then meet the criteria specified in the WHERE clause of the query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to define what data is included in the notification?

A

Only fields included in the SELECT clause of the SOQL on the PushTopic will be sent.

Only records that a User has access to will be sent

The results are returned in a JSON format with the data and event information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does security work with PushTopics?

A

Logged in User must have Read access to the PushTopic object.

Field Level security access for the fields specified in the WHERE clause

Access to the new or modified record based on sharing rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the unsupported queries in a PushTopic?

A

Queries without an ID in the select clause

Queries with relationships

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How would you deactivate a PushTopic?

A

pushTopic.isActive = false;

update pushTopic;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the CometD methods supported by Salesforce?

A

handshake
subscribe
unsubscribe
disconnect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Is Message Delivery Guaranteed?

A

Does not guarantee durability and reliable delivery of notifications. Streaming servers don’t maintain any client state and don’t keep track of what is delivered. Some events may not be processed if the system is being heavily used.

If an application server is stopped all the messages being processed but not yet sent are lost. The client must reconnect and subscribe to the channel to receive notifications.

Clients only receive notifications when a channel and subscription are active

For bulkified events that make multiple changes to records only the last change will be included in the notification

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What limits apply to the Streaming API?

A

Maximum number of

  • PushTopics
  • Clients per PushTopic
  • Concurrent clients across all PushTopics
  • Events per day
  • Length of SOQL query
  • Length for a PushTopic Name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How often does a client need to Reconnect?

A

Reconnect timeout is 40 seconds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How long is the subscription valid?

A

A client subscription is valid for a specified time irrespective of activity

The client must handshake, subscribe and connect before the session is timed out.
A new subscription creates a new session.

CometD session timeout is 2 hrs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How long is the Socket Timeout?

A

Client waits on a connection to receive events.

If no events are generated within the socket timeout, the server closes the connection.

The client should reconnect before 2 min to avoid the connection timeout.

Socket Timeout is 110 seconds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the HTTP Request limits?

A

Avoid sending multiple messages in a single request. Limit of 32,768 bytes for HTTP POST body.

If HTTP request is too large, 413 max request size exceeded error.