This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Message API reference

    Overview

    The Queue Service provided by Samsung Cloud Platform can send, receive, and delete messages.
    This guide provides an overview of the Queue Service API and how to invoke it.

    Queue Service Call Procedure

    The Queue Service API URL must be changed according to the operating environment and region. Please check the operating environment and Region information in the table below.

    Production EnvironmentRegionQueue Service URL
    For Samsungkr-west1https://queueservice.service.kr-west1.s.samsungsdscloud.com
    For Samsungkr-east1https://queueservice.service.kr-east1.s.samsungsdscloud.com
    For Enterprisekr-west1https://queueservice.service.kr-west1.e.samsungsdscloud.com
    For Enterprisekr-east1https://queueservice.service.kr-east1.e.samsungsdscloud.com

    Calling the API

    AUTH PARAMS

    Header Description
    Scp-Accesskey      : 삼성 클라우드 플랫폼 포털에서 발급받은 Access Key
    Scp-Signature      : 호출 API 요청을 Access Key와 매핑되는 Access Secret Key로 암호화한 서명. HMAC 암호화 알고리즘은 HmacSHA256 사용
    Scp-Target         : Queue Service에 요청하는 행위. ScpQS.SendMessage, ScpQS.SendMessageBatch, ScpQS.ReceiveMessage, ScpQS.DeleteMessage, ScpQS.DeleteMessageBatch 중 하나
    Scp-Timestamp      : 1970년 1월 1일 00:00:00 협정 세계시(UTC)부터의 경과 시간을 밀리초(Millisecond)로 정의합니다.
    Scp-ClientType     : user-api 명시
    

    Create Signature

    • Generate the string to be signed from the request, encrypt it with the HmacSHA256 algorithm using the Access and Secret keys, and then encode it in Base64.
    • To call the Sqeue Service via the Messaging API, you must authenticate with the “authentication key” in authentication key mode from a valid allowed IP address.
    • Use this value as the Scp-Signature.
    • The generated Signature is valid for 15 minutes.1. - Click the All Services > Application > Queue Service menu. - Go to the Service Home page of the Queue Service.
    Signature generation Sample Code (Java)
    public static String makeHmacSignature(String method,
                                           String url,
                                           String timestamp,
                                           String accessKey,
                                           String accessSecretKey,
                                           String clientType) {
    
        String body = method + url + timestamp + accessKey + clientType;
    
        String encodeBase64Str;
    
        try {
            byte[] message = body.getBytes("UTF-8");
            byte[] secretKey = accessSecretKey.getBytes("UTF-8");
    
            Mac mac = Mac.getInstance("HmacSHA256");
            SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "HmacSHA256");
            mac.init(secretKeySpec);
            byte[] hmacSha256 = mac.doFinal(message);
            encodeBase64Str = Base64.getEncoder().encodeToString(hmacSha256);
        } catch (Exception e) {
            throw new RuntimeException("Failed to calculate hmac-sha256", e);
        }
    
        return encodeBase64Str;
    }
    
    Signature generation Sample Code (JavaScript)
    <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha256.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64-min.js"></script>
    <script type="text/javascript">
    function makeSignature() {
        var method = "POST"; // Method
        var url = "{url}"; // url
        var timestamp = Date.now(); // timestamp
        var accessKey = "{accessKey}"; // access key
        var secretKey = "{secretKey}"; // secret key
        var clientType= "user-api"; // client type
    
        url = encodeURI(url); // 한글, 특수 문자 처리
    
        var message = method + url + timestamp + accessKey + clientType;
    
        var hash = CryptoJS.HmacSHA256(message, secretKey);
        return CryptoJS.enc.Base64.stringify(hash);
    }
    </script>
    

    Example of calling the Queue Service API

    Curl

    curl -i -X GET
    -H "Scp-Accesskey:2sd2gg=2agbdSD26svcD"
    -H "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef="
    -H "Scp-Timestamp:1605290625682"
    -H "Scp-ClientType:user-api"
    -H "Scp-Target:ScpQS.SendMessage"
    --data '{"MessageBody": "sample message",  "QueueUrl": "https://queueservice.kr-west1.e.samsungsdscloud.com/33ff0000a8a345d78cdf163673f3da11/samplequeue"}'
    'https://queueservice.service.kr-west1.e.samsungsdscloud.com'
    

    Python

    import requests
    
    url = "https://queueservice.service.kr-west1.e.samsungsdscloud.com"
    payload = {
       'MessageBody': 'sample message',
       'QueueUrl': 'https://queueservice.kr-west1.e.samsungsdscloud.com/33ff0000a8a345d78cdf163673f3da11/samplequeue'
    }
    headers = {
      'Scp-Accesskey': '2sd2gg=2agbdSD26svcD',
      'Scp-Signature': 'fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=',
      'Scp-Timestamp': '1605290625682',
      'Scp-ClientType': 'user-api',
      'Scp-Target': 'ScpQS.SendMessage'
    }
    
    response = requests.request("GET", url, headers=headers, data=payload)
    
    if response.status_code == 200:
        contents = response.text
        return contents
    else:
        raise Exception(f"Failed to GET API: {response.status_code}, {response.text}")
    

    Java

    String apiUrl = "https://queueservice.service.kr-west1.e.samsungsdscloud.com";
    String accessKey = "2sd2gg=2agbdSD26svcD"
    String signature = "fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef="
    String timestamp = "1605290625682"
    String clientType = "user-api"
    String scpTarget = "ScpQS.SendMessage"
    
    public static String getAPI(String token, String apiUrl) throws IOException {
            CloseableHttpClient httpClient = HttpClients.createDefault();
            HttpGet getRequest = new HttpGet(apiUrl);
            getRequest.addHeader("Scp-Accesskey", accessKey);
            getRequest.addHeader("Scp-Signature", signature);
            getRequest.addHeader("Scp-Timestamp", timestamp);
            getRequest.addHeader("Scp-ClientType", clientType);
            getRequest.addHeader("Scp-Target", scpTarget);
    
            HttpResponse response = httpClient.execute(getRequest);
            int statusCode = response.getStatusLine().getStatusCode();
    
            if (statusCode == 200) {
                String responseBody = EntityUtils.toString(response.getEntity());
                httpClient.close();
                return responseBody;
            } else {
                String responseBody = EntityUtils.toString(response.getEntity());
                httpClient.close();
                throw new RuntimeException("Failed to Request: " + statusCode + ", " + responseBody);
            }
        }
    

    Queue Service API

    SendMessage

    POST https://queueservice.service.kr-west1.e.samsungsdscloud.com
    

    Description

    Send message

    Parameters

    Field nameRequired or nottypeExplanation
    MessageAttributesfalseMessageAttribute
    MessageBodytruestring
    MessageDeduplicationIdfalsestringFIFO Queue
    MessageGroupIdfalsestringFIFO Queue
    QueueUrltruestring
    MessageAttribute
    Field nameWhether requiredtypeExplanation
    BinaryValuefalsestring
    DataTypefalsestring
    StringValuefalsestring

    Responses

    HTTP CodeDescriptionSchema
    200Created
    400Bad Request
    403Forbidden

    Example HTTP request

    Request Header
    "Scp-Accesskey:2sd2gg=2agbdSD26svcD",
    "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
    "Scp-Timestamp:1605290625682",
    "Scp-ClientType:user-api",
    "Scp-Target:ScpQS.SendMessage"
    
    Request Body
    {
      "QueueUrl": "https://queueservice.kr-west1.e.samsungsdscloud.com/123e54b7303749f38ca59a5c6d419a75/test",
      "MessageBody": "Hello SQS!",
      "MessageAttributes": {
        "Special": {
          "DataType": "string",
          "StingValue": "testBodyString12345678910!/wow$#@!"
        }
      }
    }
    

    Example HTTP response

    200 Response
    {
      "MD5OfMessageAttributes": "139818cac45117a07428826a8c533c01",
      "MD5OfMessageBody": "098f6bcd4621d373cade4e832627b4f6",
      "MessageId": "14b37b86-8117-484a-aea4-1eae3b98d5d0",
      "SequenceNumber": "11764568839"
    }
    

    SendMessageBatch

    POST https://queueservice.service.kr-west1.e.samsungsdscloud.com
    

    Description

    Mass message sending

    Parameters

    Field nameRequired or nottypeExplanation
    Entriestruearray of SendMessageBatchRequestEntry
    QueueUrltruestring
    SendMessageBatchRequestEntry
    Field nameRequired or nottypeExplanation
    Idtruestring
    MessageAttributesfalseMessageAttribute
    MessageBodytruestring
    MessageDeduplicationIdfalsestringFIFO Queue
    MessageGroupIdfalsestringFIFO Queue

    Responses

    HTTP CodeDescriptionSchema
    200Created
    400Bad Request
    403Forbidden

    Example HTTP request

    Request Header
    "Scp-Accesskey:2sd2gg=2agbdSD26svcD",
    "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
    "Scp-Timestamp:1605290625682",
    "Scp-ClientType:user-api",
    "Scp-Target:ScpQS.SendMessageBatch"
    
    Request Body
    {
       "QueueUrl": "https://queueservice.kr-west1.dev3.samsungsdscloud.com/123e54b7303749f38ca59a5c6d419a75/test",
       "Entries": [
          {
             "Id": "1",
             "MessageBody": "test-body-1"
          },
          {
             "Id": "2",
             "MessageBody": "test-body-2"
          }
       ]
    }
    

    Example HTTP response

    200 Response
    {
       "Failed": [],
       "Successful": [
          {
             "Id": "2",
             "MD5OfMessageAttributes": "d41d8cd98f00b204e9800998ecf8427e",
             "MD5OfMessageBody": "82ddf04637119b9a77e9b44095f5ba11",
             "MessageId": "68aa4629-bfbc-4bb0-898b-52db94438526",
             "SequenceNumber": "31764583416"
          },
          {
             "Id": "1",
             "MD5OfMessageAttributes": "d41d8cd98f00b204e9800998ecf8427e",
             "MD5OfMessageBody": "8344ca2f91203b151e4d0aafc9248a8b",
             "MessageId": "3523740f-9e7c-429e-8514-5ec21b1d3cd8",
             "SequenceNumber": "41764583416"
          }
       ]
    }
    

    ReceiveMessage

    POST https://queueservice.service.kr-west1.e.samsungsdscloud.com
    

    Description

    Message reception

    Parameters

    Field nameRequired statustypeExplanation
    MaxNumberOfMessagesfalsestring
    MessageAttributeNamesfalsearray of string
    MessageSystemAttributeNamesfalsearray of string
    QueueUrltruestring
    WaitTimeSecondsfalsestring

    Responses

    HTTP CodeDescriptionSchema
    200Created
    400Bad Request
    403Forbidden

    Example HTTP request

    Request Header
    "Scp-Accesskey:2sd2gg=2agbdSD26svcD",
    "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
    "Scp-Timestamp:1605290625682",
    "Scp-ClientType:user-api",
    "Scp-Target:ScpQS.ReceiveMessage"
    
    Request Body
    {
       "QueueUrl": "https://queueservice.kr-west1.dev3.samsungsdscloud.com/123e54b7303749f38ca59a5c6d419a75/test",
       "MaxNumberOfMessages": "2"
    }
    

    Example HTTP response

    200 Response
    {
       "messages": [
          {
             "MessageId": "14b37b86-8117-484a-aea4-1eae3b98d5d0",
             "Body": "sample-body-1",
             "Attributes": {},
             "MessageAttributes": {
                "Special": {
                   "DataType": "string",
                   "StingValue": "testBodyString12345678910!/wow$#@!"
                }
             },
             "MD5OfBody": "098f6bcd4621d373cade4e832627b4f6",
             "MD5OfMessageAttributes": "139818cac45117a07428826a8c533c01",
             "ReceiptHandle": "400tf1nY4HbXEP7UX4OtxPVIPlq9vw1eeKDFwNMeNiEuZvMSbvdPCBOF/P96FUF9XT7TALMzP91ViCxQjnOIyBWw+fr4EhihdJ0Z2QHau1LMHbxD+GngcM2Pv6d5HM4KCmBgB2GxFA5qpUFBPPI="
          },
          {
             "MessageId": "aee85517-1437-4877-8de8-00eee69e11dc",
             "Body": "sample-body-2",
             "Attributes": {},
             "MD5OfBody": "ad0234829205b9033196ba818f7a872b",
             "MD5OfMessageAttributes": "139818cac45117a07428826a8c533c01",
             "ReceiptHandle": "400tf1nY4HbXEP7UX4OtxPVIPlq9vw1eeKDFwNMeNiEuZvMSbvdPCBPVrfhxFxZ0XD7aBbEzP91Vi3pQ13KMxBWxrP74REyhKcgd2VLauFLMHbxD+GngcM2Pv6d5HCzyqhEoB9DHI5NmOhgaOJ4="
          }
       ]
    }
    

    DeleteMessage

    POST https://queueservice.service.kr-west1.e.samsungsdscloud.com
    

    Description

    Delete message

    Parameters

    Field nameWhether requiredtypeExplanation
    QueueUrltruestring
    ReceiptHandletruestring

    Responses

    HTTP CodeDescriptionSchema
    200Created
    400Bad Request
    403Forbidden

    Example HTTP request

    Request Header
    "Scp-Accesskey:2sd2gg=2agbdSD26svcD",
    "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
    "Scp-Timestamp:1605290625682",
    "Scp-ClientType:user-api",
    "Scp-Target:ScpQS.DeleteMessage"
    
    Request Body
    {
       "QueueUrl": "https://queueservice.kr-west1.dev3.samsungsdscloud.com/123e54b7303749f38ca59a5c6d419a75/test",
       "ReceiptHandle": "400tf1nY4HbXEP7UX4OtxPVIPlq9vw1eeKDFwNMeNiEuZvMSbvdPCBPVrfhxFxZ0XD7aBbEzP91Vi3pQ13KMxBWxrP74REyhKcgd2VLauFLMHbxD+GngcM2Pv6d5HCzyqhEoB9DHI5NmOhgaOJ4="
    }
    

    Example HTTP response

    200 Response

    DeleteMessageBatch

    POST https://queueservice.service.kr-west1.e.samsungsdscloud.com
    

    Description

    Bulk message deletion

    Parameters

    Field nameWhether requiredtypeExplanation
    Entriestruearray of DeleteMessageBatchRequestEntry
    QueueUrltruestring
    DeleteMessageBatchRequestEntry
    Field nameWhether requiredtypeExplanation
    Idtruestring
    ReceiptHandletruestring

    Responses

    HTTP CodeDescriptionSchema
    200Created
    400Bad Request
    403Forbidden

    Example HTTP request

    Request Header
    "Scp-Accesskey:2sd2gg=2agbdSD26svcD",
    "Scp-Signature:fsfsdf235f9U35sdgf35Xsf/qgsdgsdg326=sfsdr23rsef=",
    "Scp-Timestamp:1605290625682",
    "Scp-ClientType:user-api",
    "Scp-Target:ScpQS.DeleteMessageBatch"
    
    Request Body
    {
       "QueueUrl": "https://queueservice.kr-west1.dev3.samsungsdscloud.com/123e54b7303749f38ca59a5c6d419a75/test",
       "Entries": [
          {
             "Id": "1",
             "ReceiptHandle": "400tf1nY4HbXEP7UX4OtxPVIPlq9vw1eeKDFwNMeNiEuZvMSbvdPCBOF/P96FUF9XT7TALMzP91ViCxQjnOIyBWw+fr4EhihdJ0Z2QHau1LMHbxD+GngcMyJvqN5F17gym/YF4JoroeBXMSvIG0="
          },
          {
             "Id": "2",
             "ReceiptHandle": "400tf1nY4HbXEP7UX4OtxPVIPlq9vw1eeKDFwNMeNiEuZvMSbvdPCBOC8PwoFhV3Uj6JV+BnP90P3n1Q1y/RnhW0rv//GE6sf8EZjwfauVLMHbxD+GngcMyJvqN5F1Hs5T3vAZxgIV20IPdscTQ="
          }
       ]
    }
    

    Example HTTP response

    200 Response
    {
       "Failed": [],
       "Successful": [
          {
             "Id": "1"
          },
          {
             "Id": "2"
          }
       ]
    }