Receive message
If subscription type is Pull
If the subscription type is created as Pull
in the Pub/Sub, the user can receive a message through the subscription and then confirm the response.
For detailed instructions on creating a subscription, please refer to the Createsubscription.
To request message reception via API, you must obtain an access key ID and a secret access key from the KakaoCloud Console > User profile (Top right) > Access key tab.
Key Concepts
Main Concepts | Description |
---|---|
Subscription type | Pull : User requests message transmission |
Response waite time | Time to wait for message confirmation response |
Acknowledge response | If message confirmation processing (ack) is not performed within the response waiting time, the message is resent |
Receive message (Pull type)
If the subscription type is Pull
, you can receive messages via the console or API.
You can check the messages published to the topic through the reception test on the console.
To perform a reception test, you must first publish a message to the topic. For more information, refer to the Publish message.
- Go to KakaoCloud Console > Analytics > Pub/Sub.
- In the Topic menu, select a topic.
- In the Message tab, set test items and click the [Retrieve message] button.
Category | Description |
---|---|
Message details | Content of the body of the published message, if none, displayed as - |
Publish time | Time the message was published |
Attributes | Attribute value of the published message, click View Attribute to check Key, Value |
Retry attempts | Number of times the message was reprocessed |
Acknowledgement | Confirmation status according to message response waiting time |
- You can check detailed message contents by clicking Message details or View attributes in the reception test list.
Message retrieval can also be performed in the Message tab of the subscription details page.
If subscription type is Push
If you select Push
as the subscription type, here's how to receive messages:
Key Concepts
Key Concepts | Description |
---|---|
Subscription type | Push: Send messages to the Endpoint you set in Pub/Sub |
Endpoint URL | Endpoint server URL to receive messages published to the topic |
Wait Time for Response | Time to Wait for Message Acknowledgement Response |
Acknowledgement response | If there is no HTTP Response from the Endpoint registered by the user within the response waiting time, the message is resent |
If you use the Push
subscription type, you can Push Message only with an endpoint URL using KakaoCloud public IP.
Configure security group
If you use a Push type subscription, you need to set up a security group to send messages to the endpoint server.
- You need to set an inbound policy for the security group of the resource connected to the set endpoint URL.
- You can Push even if you set the bandwidth to Any, but it is recommended to specify a Source IP because it is vulnerable to security.
For security reasons, ports 22, 1433, 1521, 3306, 3389, 6379, 27017 cannot be set as Push endpoints.
Source IP range to open security groups for using Default-Topic Push subscriptions
kr-central-2
Source IP: 61.109.235.11
Source IP range to open security groups for using User Topic Push subscriptions
kr-central-2
Source IP: 61.109.238.137, 61.109.238.107, 61.109.237.249, 61.109.238.114, 61.109.238.74, 61.109.236.65
For detailed information on security groups, please refer to the Create and manage security group document.
- Select the VPC menu in the KakaoCloud Console.
- Click the Security Group menu, then select the security group to set the inbound policy.
- However, you must select the security group of the resource connected to the endpoint URL.
- Click the [Manage inbound rules] button on the Inbound rules tab, then set the inbound policy to the security group.
Receive message (Push type)
When a message is published to a topic, it is delivered to the configured endpoint in the following format.
To receive messages at the push endpoint, the POST request sent by Pub/Sub must be handled.
"subscription": string
"messages": [
{
"message": {
"data": string,
"attributes": map[string][]string
"messageId": string,
"publishTime": time (RFC3339)
}
},
{
"message": {
"data": string,
"attributes": map[string][]string
"messageId": string,
"publishTime": time (RFC3339)
}
}
]
If subscription type is Object Storage
If the subscription type is set to Object Storage
in the Pub/Sub service, users can send messages to an Object Storage bucket through the subscription.
An Object Storage bucket must be created in advance, and the Pub/Sub service agent must have write permissions for the bucket.
The Pub/Sub service agent is automatically created when the Pub/Sub service starts. For more details, refer to the Service agent account.
Main concepts
Item | Description |
---|---|
Bucket | The Object Storage bucket where messages will be stored. ⚠️ Ensure the bucket is created and the Pub/Sub service agent has write permissions before use. |
File format | The format of the output file stored in the bucket: {Bucket Name}/{YYYY/MM/DD/HH}/{UUID} - {YYYY/MM/DD/HH}: Date and time of message publishing - Time {HH}: In UTC Example Output File 2024/11/19/04/UUID |
File prefix (optional) | Includes a prefix in all output files if set. {Bucket Name}/{Prefix Path}/{YYYY/MM/DD/HH}/{Prefix Name}{UUID} Prefix Example - For filename: pubsub_ 2024/11/19/04/pubsub_UUID - For file path + filename: pubsub/message_data/test_ pubsub/message_data/2024/11/19/04/test_UUID |
File suffix (optional) | Includes a suffix in all output files if set. {Bucket Name}/{YYYY/MM/DD/HH}/{UUID}{Suffix Name} Suffix Example - For filename: _pubsub 2024/11/19/04/UUID_pubsub - For filename + extension: _pubsub.log 2024/11/19/04/UUID_pubsub.log |
File batch processing maximum duration | Stores files in the bucket at intervals of the specified duration. |
Export channel count | The number of channels used for exporting messages to Object Storage. |
Receive message (Object Storage type)
Messages are uploaded to the bucket in multipart format.
Multipart uploads that cannot be seen in the console may be stored due to upload errors or cancellations. It is recommended to create a lifecycle configuration to permanently delete incomplete multipart uploads.
Object Storage file upload example
Object Storage file upload example
When using the Object Storage subscription type, message content (data) must be included when publishing a message.
Only the message content (data) is stored in the file; message attributes are not stored.
Export channel
When an Object Storage subscription is created, an export channel is automatically activated to transfer messages to the bucket.
(*Enabling or disabling the export channel is currently supported only in the console.)
Export channel deactivation policy
If the export channel is deactivated, the transfer of messages to Object Storage stops. However, unprocessed messages at the time of deactivation may still be uploaded to Object Storage in multipart format.
If issues such as lack of bucket permissions or missing buckets occur, the export channel is automatically deactivated.
Follow the steps below and re-enable the [Start export] action.
- If the Object Storage subscription status is
InvalidBucket
orUnauthorized
, the export channel is deactivated:InvalidBucket
: Create a new bucket and update the subscription bucket information.Unauthorized
: Change to a new bucket or update permissions for the existing bucket.
- After resolving the issue, ensure the subscription status is updated back to
Active
. - Navigate to the subscription detail page and re-enable the export channel by executing [Start export].