public CreateQueueResult createQueue()

in src/main/java/com/amazonaws/services/sqs/AmazonSQSTemporaryQueuesClient.java [117:142]


    public CreateQueueResult createQueue(CreateQueueRequest request) {
        // Check for unsupported queue attributes first
        Set<String> unsupportedQueueAttributes = new HashSet<>(request.getAttributes().keySet());
        unsupportedQueueAttributes.removeAll(SUPPORTED_QUEUE_ATTRIBUTES);
        if (!unsupportedQueueAttributes.isEmpty()) {
            throw new IllegalArgumentException("Cannot create a temporary queue with the following attributes: "
                    + String.join(", ", unsupportedQueueAttributes));
        }

        Map<String, String> extraQueueAttributes = new HashMap<>();
        // Add the retention period to both the host queue and each virtual queue
        extraQueueAttributes.put(Constants.IDLE_QUEUE_RETENTION_PERIOD, Long.toString(idleQueueRetentionPeriodSeconds));
        String hostQueueUrl = hostQueueUrls.computeIfAbsent(request.getAttributes(), attributes -> {
            CreateQueueRequest hostQueueCreateRequest = SQSQueueUtils.copyWithExtraAttributes(request, extraQueueAttributes);
            hostQueueCreateRequest.setQueueName(prefix + '-' + hostQueueUrls.size());
            return amazonSqsToBeExtended.createQueue(hostQueueCreateRequest).getQueueUrl();
        });

        extraQueueAttributes.put(Constants.VIRTUAL_QUEUE_HOST_QUEUE_ATTRIBUTE, hostQueueUrl);
        // The host queue takes care of all the other queue attributes, so don't specify them when creating the virtual
        // queue or else the client may think we're trying to set them independently!
        CreateQueueRequest createVirtualQueueRequest = new CreateQueueRequest()
                .withQueueName(request.getQueueName())
                .withAttributes(extraQueueAttributes);
        return amazonSqsToBeExtended.createQueue(createVirtualQueueRequest);
    }