• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java QueueDoesNotExistException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.sqs.model.QueueDoesNotExistException的典型用法代码示例。如果您正苦于以下问题:Java QueueDoesNotExistException类的具体用法?Java QueueDoesNotExistException怎么用?Java QueueDoesNotExistException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueueDoesNotExistException类属于com.amazonaws.services.sqs.model包,在下文中一共展示了QueueDoesNotExistException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getUrlForQueue

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
/**
 * Retrieves queue url for the given queue name. If the queue does not exist, tries to create it.
 *
 * @param queueName the queue name to get url for
 * @return an optional String representing the queue url
 */
Optional<String> getUrlForQueue(String queueName) {
    Optional<String> queueUrl = Optional.empty();
    try {
        GetQueueUrlResult queueUrlResult = sqs.getQueueUrl(queueName);
        if (queueUrlResult.getQueueUrl() != null) {
            queueUrl = Optional.of(queueUrlResult.getQueueUrl());
        }
    } catch (QueueDoesNotExistException e) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Queue " + queueName + " does not exist, try to create it",e);
        }
        CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
        try {
            queueUrl = Optional.of(sqs.createQueue(createQueueRequest).getQueueUrl());
        } catch (AmazonClientException e2) {
            LOGGER.error("Could not create queue " + queueName + ", bundle won't work",e2);
        }
    }

    return queueUrl;
}
 
开发者ID:sjarrin,项目名称:dropwizard-sqs-bundle,代码行数:28,代码来源:SqsBundle.java


示例2: shouldCreateNewQueueWhenNoQueueUrlIsFound

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test
public void shouldCreateNewQueueWhenNoQueueUrlIsFound() throws Exception {
    //GIVEN
    AmazonSQS sqs = mock(AmazonSQS.class);
    field("sqs").ofType(AmazonSQS.class).in(bundle).set(sqs);

    String queueUrl = "https://eu-central-1/queue.amazonaws.com/123456/test-queue";
    when(sqs.getQueueUrl("test-queue")).thenThrow(new QueueDoesNotExistException("Simulates that queue does not exist"));
    when(sqs.createQueue(new CreateQueueRequest("test-queue"))).thenReturn(new CreateQueueResult().withQueueUrl(queueUrl));

    //WHEN
    Optional<String> urlForQueue = bundle.getUrlForQueue("test-queue");

    //THEN
    assertThat(urlForQueue.isPresent()).isTrue();
    assertThat(urlForQueue.get()).isEqualTo(queueUrl);
}
 
开发者ID:sjarrin,项目名称:dropwizard-sqs-bundle,代码行数:18,代码来源:SqsBundleTest.java


示例3: initQueue

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
private void initQueue() {
	this.sqs = new AmazonSQSClient(); // Do we need to use new
										// ClientConfiguration().withMaxConnections(256)
										// ?
	this.sqs.configureRegion(region);
	try {
		// Check to see if queue exists
		GetQueueUrlResult queueUrlResult = this.sqs.getQueueUrl(getSqsQueueName());
		this.queueUrl = queueUrlResult.getQueueUrl();
	} catch (QueueDoesNotExistException queueDoesNotExist) {
		// Queue does not exist, need to create one
		CreateQueueRequest createQueueRequest = new CreateQueueRequest();
		createQueueRequest.setQueueName(getSqsQueueName());
		createQueueRequest.addAttributesEntry("VisibilityTimeout", "" + getVisibilityTimeout());
		CreateQueueResult createQueueResult = this.sqs.createQueue(createQueueRequest);
		this.queueUrl = createQueueResult.getQueueUrl();
	}
}
 
开发者ID:olegdulin,项目名称:sqs-retryqueue,代码行数:19,代码来源:SQSRetryQueue.java


示例4: getAndSetQueueUrl

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
/**
 * Get a queue url from a queue name
 * @param queueName
 * @return queueUrl - For the specified queue name
 */
private synchronized String getAndSetQueueUrl(final String queueName) throws QueueDoesNotExistException{
	try{

		final String url = queueUrlMap.get(queueName); 
		if(url != null){
			return url;
		}else{
			final GetQueueUrlResult result = this.sqs.getQueueUrl(queueName);
			if(result != null && !Strings.isNullOrEmpty(result.getQueueUrl())){
					queueUrlMap.put(queueName, result.getQueueUrl());	
					return result.getQueueUrl();
			}				
		}
	}catch(QueueDoesNotExistException qne){
		throw qne;
	}catch(Exception ex){
		throw new RuntimeException(ex.getMessage(), ex);
	}
	return null;
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:26,代码来源:SqsQueueAdmin.java


示例5: createQueueAndConfigIfNotExists

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
private void createQueueAndConfigIfNotExists(final String queue, final MessageHandler handler) {
	
	/** determine if the queue exists, if not, create it with the default settings **/
	try{
		final String url = this.admin.getQueueUrl(queue);
		if(Strings.isNullOrEmpty(url)){
			throw new QueueDoesNotExistException(String.format("The queue: %s was not found", queue));
		}
	}catch(QueueDoesNotExistException qneException){
		/** determine if the queue configuration exists **/
		SqsQueueConfig queueConfig = this.queueConfigMap.get(queue);
		if(queueConfig==null){
			/** create default config if we don't know about it **/
			queueConfig = new SqsQueueConfig();
			queueConfig.setName(queue);
			this.queueConfigMap.put(queue, queueConfig);
		}
		LOGGER.info("Queue: {} does not exist - creating the queue now", queue);
		this.admin.initializeQueue(queueConfig, this.config.isBlockUntilReady());
	}
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:22,代码来源:SqsFactory.java


示例6: resolveDestination

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Override
public String resolveDestination(String name) throws DestinationResolutionException {
    String queueName = name;

    if (this.resourceIdResolver != null) {
        queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name);
    }

    if (isValidQueueUrl(queueName)) {
        return queueName;
    }

    if (this.autoCreate) {
        //Auto-create is fine to be called even if the queue exists.
        CreateQueueResult createQueueResult = this.amazonSqs.createQueue(new CreateQueueRequest(queueName));
        return createQueueResult.getQueueUrl();
    } else {
        try {
            GetQueueUrlResult getQueueUrlResult = this.amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueName));
            return getQueueUrlResult.getQueueUrl();
        } catch (QueueDoesNotExistException e) {
            throw new DestinationResolutionException(e.getMessage(), e);
        }
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:26,代码来源:DynamicQueueUrlDestinationResolver.java


示例7: queryQueueUrl

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
private String queryQueueUrl(String queueName) {
    try {
        return _sqs.getQueueUrl(new GetQueueUrlRequest(queueName)).getQueueUrl();
    } catch (QueueDoesNotExistException e) {
        // Create the queue
        int visibilityTimeout = queueName.equals(_pendingScanRangeQueue) ?
                DEFAULT_TASK_CLAIM_VISIBILITY_TIMEOUT : DEFAULT_TASK_COMPLETE_VISIBILITY_TIMEOUT;
        return _sqs.createQueue(
                new CreateQueueRequest(queueName)
                        .withAttributes(ImmutableMap.<String, String>of(
                                "VisibilityTimeout", String.valueOf(visibilityTimeout)))
        ).getQueueUrl();
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:15,代码来源:SQSScanWorkflow.java


示例8: poll

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Override
protected int poll() throws Exception {
    // must reset for each poll
    shutdownRunningTask = null;
    pendingExchanges = 0;
    
    ReceiveMessageRequest request = new ReceiveMessageRequest(getQueueUrl());
    request.setMaxNumberOfMessages(getMaxMessagesPerPoll() > 0 ? getMaxMessagesPerPoll() : null);
    request.setVisibilityTimeout(getConfiguration().getVisibilityTimeout() != null ? getConfiguration().getVisibilityTimeout() : null);
    request.setWaitTimeSeconds(getConfiguration().getWaitTimeSeconds() != null ? getConfiguration().getWaitTimeSeconds() : null);

    if (attributeNames != null) {
        request.setAttributeNames(attributeNames);
    }
    if (messageAttributeNames != null) {
        request.setMessageAttributeNames(messageAttributeNames);
    }

    LOG.trace("Receiving messages with request [{}]...", request);
    
    ReceiveMessageResult messageResult = null;
    try {
        messageResult = getClient().receiveMessage(request);
    } catch (QueueDoesNotExistException e) {
        LOG.info("Queue does not exist....recreating now...");
        reConnectToQueue();
        messageResult = getClient().receiveMessage(request);
    }

    if (LOG.isTraceEnabled()) {
        LOG.trace("Received {} messages", messageResult.getMessages().size());
    }
    
    Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
    return processBatch(CastUtils.cast(exchanges));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:SqsConsumer.java


示例9: getQueueUrl

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
private String getQueueUrl(String queueName, boolean createIfNotExist) {
	try {
		return _sqs.getQueueUrl(queueName).getQueueUrl();
	} catch (QueueDoesNotExistException e) {
		if (createIfNotExist) {
			logger.info("Creating SQS queue called: " + queueName);
			return createQueue(queueName);
		}
		
		throw e;
	}
}
 
开发者ID:apelyos,项目名称:distributed-image-classification,代码行数:13,代码来源:Queue.java


示例10: stillExists

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
public boolean stillExists() {
	try {
		_sqs.getQueueUrl(_queueName);
		return true;
	} catch (QueueDoesNotExistException e) {
		return false;
	}
}
 
开发者ID:apelyos,项目名称:distributed-image-classification,代码行数:9,代码来源:Queue.java


示例11: sendMessage

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Override
public SendMessageResult sendMessage(String queueName, String messageText, Map<String, MessageAttributeValue> messageAttributes, AmazonSQS amazonSQS)
{
    try
    {
        return amazonSQS.sendMessage(new SendMessageRequest().withQueueUrl(amazonSQS.getQueueUrl(queueName).getQueueUrl()).withMessageBody(messageText)
            .withMessageAttributes(messageAttributes));
    }
    catch (QueueDoesNotExistException e)
    {
        throw new IllegalStateException(String.format("AWS SQS queue with \"%s\" name not found.", queueName), e);
    }
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:14,代码来源:SqsOperationsImpl.java


示例12: shouldThrowExceptionWhenCreatingSenderIfQueueDoesNotExists

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test(expected = CannotCreateSenderException.class)
public void shouldThrowExceptionWhenCreatingSenderIfQueueDoesNotExists() throws Exception, CannotCreateSenderException {
    //GIVEN
    AmazonSQS sqs = mock(AmazonSQS.class);
    field("sqs").ofType(AmazonSQS.class).in(bundle).set(sqs);

    when(sqs.getQueueUrl(anyString())).thenThrow(new QueueDoesNotExistException("Simulate queue does not exist"));
    when(sqs.createQueue((CreateQueueRequest) any())).thenThrow(new AmazonClientException("Simulate queue cannot be created"));

    //WHEN
    bundle.createSender("test-queue");

    //THEN
}
 
开发者ID:sjarrin,项目名称:dropwizard-sqs-bundle,代码行数:15,代码来源:SqsBundleTest.java


示例13: postConstruct

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@PostConstruct
public void postConstruct() {
    // for each configured queue set up the data structure to manage the current message batch

    String queuesProperty = StringUtils.trim(config.getString(QUEUE_NAMES_PROPERTY));
    Validate.notEmpty(queuesProperty);

    String[] queues = StringUtils.split(queuesProperty, "| ");

    // Initialize the message and queue URLs
    Map<String, LinkedBlockingQueue<Message>> tempMessagesMap = new HashMap<>(queues.length);
    Map<String, String> tempQueueUrls = new HashMap<>(queues.length);

    for (String queue : queues) {
        queue = StringUtils.trim(queue);
        String queueUrl;

        logger.info("Initializing queue " + queue);

        try {
            queueUrl = sqsClient.getQueueUrl(queue).getQueueUrl();
        } catch (QueueDoesNotExistException ex) {
            queueUrl = sqsClient.createQueue(queue).getQueueUrl();
        }

        tempMessagesMap.put(queue, new LinkedBlockingQueue<>());
        tempQueueUrls.put(queue, queueUrl);
    }

    messagesMap = Collections.unmodifiableMap(tempMessagesMap);
    queueUrls = Collections.unmodifiableMap(tempQueueUrls);

    // Start the async operation
    executorService.submit(messagePoller);
}
 
开发者ID:ScottMansfield,项目名称:widow,代码行数:36,代码来源:QueueManager.java


示例14: getQueueUrl

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
/**
 * Get the queue url. First an internal cache is checked, if the name to queueUrl mapping
 * is not found in the internal cache a call is made to the Sqs API. If a valid queue
 * url is returned the name -> queueUrl mapping will be cached locally 
 * @param queueName
 * @return queueUrl
 */
public String getQueueUrl(final String queueName) throws QueueDoesNotExistException{

	Preconditions.checkArgument(!Strings.isNullOrEmpty(queueName), "Queue Name is required in order to submit a message for sqs");
	String url = queueUrlMap.get(queueName);
	if(url!=null){
		return url;
	}else{
		return this.getAndSetQueueUrl(queueName);
	}
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:18,代码来源:SqsQueueAdmin.java


示例15: testInvalidDestinationName

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test
public void testInvalidDestinationName() throws Exception {
    AmazonSQS amazonSqs = mock(AmazonSQS.class);
    AmazonServiceException exception = new QueueDoesNotExistException("AWS.SimpleQueueService.NonExistentQueue");
    exception.setErrorCode("AWS.SimpleQueueService.NonExistentQueue");
    String queueUrl = "invalidName";
    when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueUrl))).thenThrow(exception);
    DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver(amazonSqs);
    try {
        dynamicQueueDestinationResolver.resolveDestination(queueUrl);
    } catch (DestinationResolutionException e) {
        assertTrue(e.getMessage().startsWith("AWS.SimpleQueueService.NonExistentQueue"));
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:15,代码来源:DynamicQueueUrlDestinationResolverTest.java


示例16: testGetQueueUrlQueueNameThrowQueueDoesNotExistException

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test(expected = InvalidDestinationException.class)
public void testGetQueueUrlQueueNameThrowQueueDoesNotExistException() throws JMSException {

    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    doThrow(new QueueDoesNotExistException("qdnee"))
            .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));

    wrapper.getQueueUrl(QUEUE_NAME);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java


示例17: testGetQueueUrlQueueNameWithAccountIdThrowQueueDoesNotExistException

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test(expected = InvalidDestinationException.class)
public void testGetQueueUrlQueueNameWithAccountIdThrowQueueDoesNotExistException() throws JMSException {

    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    getQueueUrlRequest.setQueueOwnerAWSAccountId(OWNER_ACCOUNT_ID);
    doThrow(new QueueDoesNotExistException("qdnee"))
            .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));

    wrapper.getQueueUrl(QUEUE_NAME,OWNER_ACCOUNT_ID);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:11,代码来源:AmazonSQSMessagingClientWrapperTest.java


示例18: testQueueExistsThrowQueueDoesNotExistException

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test
public void testQueueExistsThrowQueueDoesNotExistException() throws JMSException {

    GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME);
    doThrow(new QueueDoesNotExistException("qdnee"))
            .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest));

    assertFalse(wrapper.queueExists(QUEUE_NAME));
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java


示例19: getQueueUrl

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Override
public GetQueueUrlResult getQueueUrl(GetQueueUrlRequest getQueueUrlRequest) throws AmazonClientException {
    try {
        File topicFile = new File(_rootDirectory, getQueueUrlRequest.getQueueName());
        if (!topicFile.exists()) {
            throw new QueueDoesNotExistException("could not find a file for queue named " + getQueueUrlRequest.getQueueName());
        }
        return new GetQueueUrlResult().withQueueUrl(saveQueue(new DirectorySQSQueue(topicFile.toPath())));
    } catch (IOException e) {
        throw new AmazonServiceException("could not get queue named " + getQueueUrlRequest.getQueueName(), e);
    }
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:13,代码来源:DirectorySQS.java


示例20: cannotDeleteNonExistentQueue

import com.amazonaws.services.sqs.model.QueueDoesNotExistException; //导入依赖的package包/类
@Test(expectedExceptions = QueueDoesNotExistException.class)
public void cannotDeleteNonExistentQueue()
        throws IOException {
    _amazonSQS.deleteQueue(new DeleteQueueRequest(new File(TestUtils.createTempDirectory(), someQueueName()).toURI().toString()));
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:6,代码来源:TestSQSClient.java



注:本文中的com.amazonaws.services.sqs.model.QueueDoesNotExistException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataPusher类代码示例发布时间:2022-05-22
下一篇:
Java GroupNames类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap