SQS

LAST EDIT Feb 16 2021

Stream can send payloads of all events from your application to an Amazon SQS queue you own. The complete list of supported events is identical to those send to webhooks and can be found on the Events page.

ConfigurationCopied!

To configure an SQS queue, use the SDK to set the sqs_url, sqs_key & sqs_secret app settings.

1
2
3
4
5
6
7
8
9
// set your SQS queue details 
await client.updateAppSettings({ 
	sqs_url: 'https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue', 
	sqs_key: 'yourkey', 
	sqs_secret: 'yoursecret', 
}); 
 
//send a test message 
await client.testSQSSettings();

SQS PermissionsCopied!

Stream needs the right permissions on your SQS queue to be able to send events to it. If updates are not showing up in your queue add the following permission policy to the queue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{ 
    "Version": "2012-10-17", 
    "Statement": [ 
      { 
        "Sid": "Stmt1459523779000", 
        "Effect": "Allow", 
        "Action": [ 
          "sqs:GetQueueUrl", 
          "sqs:SendMessage", 
         "sqs:SendMessageBatch", 
         "sqs:GetQueueAttributes" 
       ], 
       "Resource": [ 
         "arn:aws:sqs:region:acc_id:queue_name" 
       ] 
     } 
   ] 
}

Here's an example list of messages read from your SQS queue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ 
   "type":"message.new", 
   "cid":"messaging:fun-d5f396e3-fbaf-469c-9b45-8837b4f75baa", 
   "message":{ 
      "id":"8bffc454-e1da-4d91-8b88-a87853dfb41c", 
      "text":"Welcome to the Community!", 
      "html":"<p>Welcome to the Community!</p>\n", 
      "type":"regular", 
      "user":{ 
         "id":"tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0", 
         "role":"user", 
         "created_at":"2020-03-30T07:54:46.207332Z", 
         "updated_at":"2020-03-30T07:54:46.207719Z", 
         "banned":false, 
         "online":false 
      }, 
      "attachments":[ 
 
      ], 
      "latest_reactions":[ 
 
      ], 
      "own_reactions":[ 
 
      ], 
      "reaction_counts":null, 
      "reaction_scores":{ 
 
      }, 
      "reply_count":0, 
      "created_at":"2020-03-30T07:54:46.277381Z", 
      "updated_at":"2020-03-30T07:54:46.277382Z", 
      "mentioned_users":[ 
 
      ] 
   }, 
   "user":{ 
      "id":"tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0", 
      "role":"user", 
      "created_at":"2020-03-30T07:54:46.207332Z", 
      "updated_at":"2020-03-30T07:54:46.207719Z", 
      "banned":false, 
      "online":false, 
      "channel_unread_count":0, 
      "channel_last_read_at":"2020-03-30T07:54:46.270208768Z", 
      "total_unread_count":0, 
      "unread_channels":0, 
      "unread_count":0 
   }, 
   "created_at":"2020-03-30T07:54:46.295138Z", 
   "members":[ 
      { 
         "user_id":"thierry-735d0d44-8bf1-40df-81db-fa83363ac790", 
         "user":[ 
            "Object" 
         ], 
         "created_at":"2020-03-30T07:54:46.255628Z", 
         "updated_at":"2020-03-30T07:54:46.255628Z" 
      }, 
      { 
         "user_id":"tommaso-52ec3a5f-e916-469f-bf54-b53b5247a4b0", 
         "user":[ 
            "Object" 
         ], 
         "created_at":"2020-03-30T07:54:46.256118Z", 
         "updated_at":"2020-03-30T07:54:46.256118Z" 
      } 
   ], 
   "channel_type":"messaging", 
   "channel_id":"fun-d5f396e3-fbaf-469c-9b45-8837b4f75baa" 
}

SQS Best practices and AssumptionsCopied!

  • Ensure to have the maximum message size set to 256 KB

Stream uses batching for updates and tries to include as many messages as possible to reduce network delays. Messages bigger than the maximum message size will be dropped.

  • Setup a dead-letter queue for your main queue

This queue will hold the messages that couldn't be processed successfully and is useful for debugging your application.