AWS Doc SDK Examples
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
または GetQueueUrl
で を使用する AWS SDK CLI
以下のコード例は、GetQueueUrl
の使用方法を示しています。
- .NET
-
- AWS SDK for .NET
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 using System; using System.Threading.Tasks; using Amazon.SQS; using Amazon.SQS.Model; public class GetQueueUrl { /// <summary> /// Initializes the Amazon SQS client object and then calls the /// GetQueueUrlAsync method to retrieve the URL of an Amazon SQS /// queue. /// </summary> public static async Task Main() { // If the Amazon SQS message queue is not in the same AWS Region as your // default user, you need to provide the AWS Region as a parameter to the // client constructor. var client = new AmazonSQSClient(); string queueName = "New-Example-Queue"; try { var response = await client.GetQueueUrlAsync(queueName); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"The URL for {queueName} is: {response.QueueUrl}"); } } catch (QueueDoesNotExistException ex) { Console.WriteLine(ex.Message); Console.WriteLine($"The queue {queueName} was not found."); } } }
-
API 詳細については、「 AWS SDK for .NET APIリファレンスGetQueueUrl」の「」を参照してください。
-
- C++
-
- SDK C++ 用
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; //! Get the URL for an Amazon Simple Queue Service (Amazon SQS) queue. /*! \param queueName: An Amazon SQS queue name. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SQS::getQueueUrl(const Aws::String &queueName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SQS::SQSClient sqsClient(clientConfiguration); Aws::SQS::Model::GetQueueUrlRequest request; request.SetQueueName(queueName); const Aws::SQS::Model::GetQueueUrlOutcome outcome = sqsClient.GetQueueUrl(request); if (outcome.IsSuccess()) { std::cout << "Queue " << queueName << " has url " << outcome.GetResult().GetQueueUrl() << std::endl; } else { std::cerr << "Error getting url for queue " << queueName << ": " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
API 詳細については、「 AWS SDK for C++ APIリファレンスGetQueueUrl」の「」を参照してください。
-
- CLI
-
- AWS CLI
-
キューを取得するには URL
この例では、指定されたキューの を取得しますURL。
コマンド:
aws sqs get-queue-url --queue-name
MyQueue
出力:
{ "QueueUrl": "https://queue.amazonaws.com/80398EXAMPLE/MyQueue" }
-
API 詳細については、AWS CLI 「 コマンドリファレンスGetQueueUrl
」の「」を参照してください。
-
- Java
-
- SDK for Java 2.x
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 GetQueueUrlResponse getQueueUrlResponse = sqsClient .getQueueUrl(GetQueueUrlRequest.builder().queueName(queueName).build()); return getQueueUrlResponse.queueUrl();
-
API 詳細については、「 AWS SDK for Java 2.x APIリファレンスGetQueueUrl」の「」を参照してください。
-
- JavaScript
-
- SDK for JavaScript (v3)
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 Amazon SQSキューURLの を取得します。
import { GetQueueUrlCommand, SQSClient } from "@aws-sdk/client-sqs"; const client = new SQSClient({}); const SQS_QUEUE_NAME = "test-queue"; export const main = async (queueName = SQS_QUEUE_NAME) => { const command = new GetQueueUrlCommand({ QueueName: queueName }); const response = await client.send(command); console.log(response); return response; };
-
詳細については、「AWS SDK for JavaScript デベロッパーガイド」を参照してください。
-
API 詳細については、「 AWS SDK for JavaScript APIリファレンスGetQueueUrl」の「」を参照してください。
-
- SDK for JavaScript (v2)
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 Amazon SQSキューURLの を取得します。
// Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create an SQS service object var sqs = new AWS.SQS({ apiVersion: "2012-11-05" }); var params = { QueueName: "SQS_QUEUE_NAME", }; sqs.getQueueUrl(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.QueueUrl); } });
-
詳細については、「AWS SDK for JavaScript デベロッパーガイド」を参照してください。
-
API 詳細については、「 AWS SDK for JavaScript APIリファレンスGetQueueUrl」の「」を参照してください。
-
- PowerShell
-
- のツール PowerShell
-
例 1: この例では、指定した名前のキューURLの を一覧表示します。
Get-SQSQueueUrl -QueueName MyQueue
出力:
https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue
-
API 詳細については、「 コマンドレットリファレンスGetQueueUrl」の「」を参照してください。 AWS Tools for PowerShell
-
- Python
-
- SDK for Python (Boto3)
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 def get_queue(name): """ Gets an SQS queue by name. :param name: The name that was used to create the queue. :return: A Queue object. """ try: queue = sqs.get_queue_by_name(QueueName=name) logger.info("Got queue '%s' with URL=%s", name, queue.url) except ClientError as error: logger.exception("Couldn't get queue named %s.", name) raise error else: return queue
-
API 詳細については、「 for AWS SDKPython (Boto3) APIリファレンスGetQueueUrl」の「」を参照してください。
-
- SAP ABAP
-
- SDK の SAP ABAP
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. oo_result = lo_sqs->getqueueurl( iv_queuename = iv_queue_name ). " oo_result is returned for testing purposes. " MESSAGE 'Queue URL retrieved.' TYPE 'I'. CATCH /aws1/cx_sqsqueuedoesnotexist. MESSAGE 'The requested queue does not exist.' TYPE 'E'. ENDTRY.
-
API 詳細については、GetQueueUrl「」のAWS SDKSAPABAPAPI「」を参照してください。
-