Skip to main content

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.

info

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 ConceptsDescription
Subscription typePull: User requests message transmission
Response waite timeTime to wait for message confirmation response
Acknowledge responseIf 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.

info

To perform a reception test, you must first publish a message to the topic. For more information, refer to the Publish message.

  1. Go to KakaoCloud Console > Analytics > Pub/Sub.
  2. In the Topic menu, select a topic.
  3. In the Message tab, set test items and click the [Retrieve message] button.
CategoryDescription
Message detailsContent of the body of the published message, if none, displayed as -
Publish timeTime the message was published
AttributesAttribute value of the published message, click View Attribute to check Key, Value
Retry attemptsNumber of times the message was reprocessed
AcknowledgementConfirmation status according to message response waiting time
  1. You can check detailed message contents by clicking Message details or View attributes in the reception test list.
info

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 ConceptsDescription
Subscription typePush: Send messages to the Endpoint you set in Pub/Sub
Endpoint URLEndpoint server URL to receive messages published to the topic
Wait Time for ResponseTime to Wait for Message Acknowledgement Response
Acknowledgement responseIf there is no HTTP Response from the Endpoint registered by the user within the response waiting time, the message is resent
info

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.
caution

For security reasons, ports 22, 1433, 1521, 3306, 3389, 6379, 27017 cannot be set as Push endpoints.

info

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.

  1. Select the VPC menu in the KakaoCloud Console.
  2. 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.
  1. 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.

Message format
"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.

info

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
ItemDescription
BucketThe 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 formatThe 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 durationStores files in the bucket at intervals of the specified duration.
Export channel countThe number of channels used for exporting messages to Object Storage.

Receive message (Object Storage type)

Messages are uploaded to the bucket in multipart format.

caution

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

Image
Object Storage file upload example

info

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.

caution

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.

  1. If the Object Storage subscription status is InvalidBucket or Unauthorized, 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.
  2. After resolving the issue, ensure the subscription status is updated back to Active.
  3. Navigate to the subscription detail page and re-enable the export channel by executing [Start export].