当前位置: 首页>>代码示例>>Java>>正文


Java ReceiveMessageRequest.setWaitTimeSeconds方法代码示例

本文整理汇总了Java中com.amazonaws.services.sqs.model.ReceiveMessageRequest.setWaitTimeSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java ReceiveMessageRequest.setWaitTimeSeconds方法的具体用法?Java ReceiveMessageRequest.setWaitTimeSeconds怎么用?Java ReceiveMessageRequest.setWaitTimeSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.sqs.model.ReceiveMessageRequest的用法示例。


在下文中一共展示了ReceiveMessageRequest.setWaitTimeSeconds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: peekMessage

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public T peekMessage(int waitFor) throws Exception {
       // Receive messages
	logger.info("Trying to recieve message from: " + _queueName);
       ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(_queueURL);
       receiveMessageRequest.setMaxNumberOfMessages(1);
       receiveMessageRequest.setWaitTimeSeconds(waitFor);
       
       List<Message> messages = _sqs.receiveMessage(receiveMessageRequest).getMessages();
       
       for (Message message : messages) {
       	logger.info("  Got Message");
       	logger.info("    Body:          " + message.getBody());
       	logger.info("    Handle:        " + message.getReceiptHandle());
           
           _lastMessage = message;
           GenericMessage msg =  GenericMessage.fromXML(message.getBody());
   		if (!msg.type.equals(_msgClass.getName()))
   			throw new Exception("Invalid message type recieved.");
   		
           return (T) msg.body;
       }
	return null;
}
 
开发者ID:apelyos,项目名称:distributed-image-classification,代码行数:25,代码来源:Queue.java

示例2: getReceiveMessageRequest

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的package包/类
public ReceiveMessageRequest getReceiveMessageRequest() {
    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(this.destinationUrl).
            withAttributeNames(RECEIVING_ATTRIBUTES).
            withMessageAttributeNames(RECEIVING_MESSAGE_ATTRIBUTES);

    if (this.maxNumberOfMessages != null) {
        receiveMessageRequest.withMaxNumberOfMessages(this.maxNumberOfMessages);
    } else {
        receiveMessageRequest.withMaxNumberOfMessages(DEFAULT_MAX_NUMBER_OF_MESSAGES);
    }

    if (this.visibilityTimeout != null) {
        receiveMessageRequest.withVisibilityTimeout(this.visibilityTimeout);
    }

    if (this.waitTimeOut != null) {
        receiveMessageRequest.setWaitTimeSeconds(this.waitTimeOut);
    }

    return receiveMessageRequest;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:22,代码来源:AbstractMessageListenerContainer.java

示例3: createReceiveMessageRequest

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的package包/类
@Override
public ReceiveMessageRequest createReceiveMessageRequest(String queueUrl, final int maxNumberMessages, final int waitTimeSeconds) {
    final ReceiveMessageRequest request = new ReceiveMessageRequest(queueUrl);
    request.setMaxNumberOfMessages(maxNumberMessages);
    request.setWaitTimeSeconds(waitTimeSeconds);
    return request;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:8,代码来源:RequestFactoryImpl.java

示例4: poll

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的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

示例5: pollQueue

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的package包/类
/**
 * Poll SQS queue for incoming messages, filter them, and return a list of SQS Messages.
 *
 * @return a list of SQS messages.
 */
public List<Message> pollQueue() {
    boolean success = false;
    ProgressStatus pollQueueStatus = new ProgressStatus(ProgressState.pollQueue, new BasicPollQueueInfo(0, success));
    final Object reportObject = progressReporter.reportStart(pollQueueStatus);

    ReceiveMessageRequest request = new ReceiveMessageRequest().withAttributeNames(ALL_ATTRIBUTES);
    request.setQueueUrl(config.getSqsUrl());
    request.setVisibilityTimeout(config.getVisibilityTimeout());
    request.setMaxNumberOfMessages(DEFAULT_SQS_MESSAGE_SIZE_LIMIT);
    request.setWaitTimeSeconds(DEFAULT_WAIT_TIME_SECONDS);

    List<Message> sqsMessages = new ArrayList<Message>();
    try {

        ReceiveMessageResult result = sqsClient.receiveMessage(request);
        sqsMessages = result.getMessages();
        logger.info("Polled " + sqsMessages.size() + " sqs messages from " + config.getSqsUrl());

        success = true;
    } catch (AmazonServiceException e) {
        LibraryUtils.handleException(exceptionHandler, pollQueueStatus, e, "Failed to poll sqs message.");

    } finally {
        LibraryUtils.endToProcess(progressReporter, success, pollQueueStatus, reportObject);
    }
    return sqsMessages;

}
 
开发者ID:aws,项目名称:aws-cloudtrail-processing-library,代码行数:34,代码来源:SqsManager.java

示例6: getReceiveMessageRequest

import com.amazonaws.services.sqs.model.ReceiveMessageRequest; //导入方法依赖的package包/类
/**
 * Override to provide defaults to the sqs message request.
 * @return
 */
default ReceiveMessageRequest getReceiveMessageRequest() {
    ReceiveMessageRequest request = new ReceiveMessageRequest();
    request.setWaitTimeSeconds(20);
    return request;
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:10,代码来源:Consumer.java


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