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


Java Message.getReceiptHandle方法代码示例

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


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

示例1: getMessages

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
public List<QueueMessage> getMessages() {

        ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(_queueDns);
        List<Message> messages = _sqs.receiveMessage(receiveMessageRequest).getMessages();

        List<QueueMessage> deserializedMessages = new ArrayList<>();

        for (Message message : messages) {
            String body = message.getBody();
            QueueMessage qm = _gson.fromJson(body, QueueMessage.class);
            deserializedMessages.add(qm);

            System.out.println("query time: " + qm.queryExecutionTime);
            System.out.println("exec time: " + qm.totalExecutionTime);
            System.out.println("Has ex: " + qm.hasException);
            System.out.println("ex message: " + qm.exceptionMessage + "\n");

            String receiptHandle = message.getReceiptHandle();
            _sqs.deleteMessage(new DeleteMessageRequest(_queueDns, receiptHandle));
        }

        return deserializedMessages;
    }
 
开发者ID:hunterSThompson,项目名称:aws-ski-resort,代码行数:24,代码来源:QueueService.java

示例2: deleteMessage

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private void deleteMessage(Message message) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Delete message " + message);
    }
    String messageReceiptHandle = message.getReceiptHandle();
    sqs.deleteMessage(new DeleteMessageRequest(queueUrl, messageReceiptHandle));
}
 
开发者ID:sjarrin,项目名称:dropwizard-sqs-bundle,代码行数:8,代码来源:SqsReceiverHandler.java

示例3: remoteBatchReceive

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
	public void remoteBatchReceive(PrintWriter out) throws ParseException{
    	JSONArray responseList = new JSONArray();
    	JSONParser parser=new JSONParser();
    	    	
    	while(msg_cnt > 0){ 
	    	while(resQ.getQueueSize() > 0){
	    		//Get up to 10 messages
	    		 List<Message> messages = resQ.batchReceive();
			      		     
			     for (Message message : messages) {
//			    	 System.out.println("  Message");
//			         System.out.println("    MessageId:     " + message.getMessageId());
//			         System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
//			         System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
//			         System.out.println("    Body:          " + message.getBody());
		          
		            //Get task
		            String messageBody = message.getBody();		           
		            JSONObject resp = (JSONObject)parser.parse(messageBody);
		            responseList.add(resp);
		            		            	            
		            msg_cnt--;
		            // Delete the message
                    String messageRecieptHandle = message.getReceiptHandle();
                    resQ.deleteMessage(messageRecieptHandle);

		        }
			    if(!responseList.isEmpty()){
			    	 out.println(responseList.toString());
			    	 responseList.clear();
			    }
			    
	    	}
    	}  	 
    }
 
开发者ID:cs553-cloud-computing,项目名称:amazon-cloudengine,代码行数:37,代码来源:ServerThread.java

示例4: verifyReceiveEmail

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private String verifyReceiveEmail(String expectedMessageId, String queueUrl, Integer visibilityTimeout) {
    final ReceiveMessageResult receiveResult = _amazonSQS.receiveMessage(new ReceiveMessageRequest(queueUrl).withVisibilityTimeout(visibilityTimeout));

    Assert.assertEquals(receiveResult.getMessages().size(), 1, "Expected one message");

    final Message message = receiveResult.getMessages().get(0);
    Assert.assertEquals(message.getMessageId(), expectedMessageId);
    return message.getReceiptHandle();
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:10,代码来源:TestSQSClient.java

示例5: doReceive

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
protected void doReceive() {
	// This is where the interesting stuff happens
	while (isListening()) {
		synchronized (this.monitor) {
			try {
				this.monitor.wait(this.getVisibilityTimeout() * 1000);
			} catch (InterruptedException e) {

			}
		}
		boolean messagesReceived = false;
		do {
			ReceiveMessageRequest request = new ReceiveMessageRequest().withQueueUrl(this.queueUrl)
					.withWaitTimeSeconds(1).withMaxNumberOfMessages(10);
			ReceiveMessageResult result = sqs.receiveMessage(request);
			List<Message> messages = result.getMessages();
			messagesReceived = messages.size() > 0;
			if (!messagesReceived) {
				break;
			}
			List<DeleteMessageBatchRequestEntry> deletes = new ArrayList<DeleteMessageBatchRequestEntry>();
			for (Message message : messages) {
				String messageBody = message.getBody();
				try {
					this.messageConsumer.accept(messageBody);
					DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(
							UUID.randomUUID().toString(), message.getReceiptHandle());
					deletes.add(entry);
				} catch (Throwable exp) {
					Logger.getLogger(getSqsQueueName()).log(Level.WARNING,
							"Could not process message: " + messageBody, exp);
				}
			}
			if (!deletes.isEmpty()) {
				DeleteMessageBatchRequest deleteBatch = new DeleteMessageBatchRequest(this.queueUrl, deletes);
				sqs.deleteMessageBatch(deleteBatch);
			}
		} while (messagesReceived);
	}

}
 
开发者ID:olegdulin,项目名称:sqs-retryqueue,代码行数:42,代码来源:SQSRetryQueue.java

示例6: toMessage

import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Override
protected BasicMessage toMessage(final Message sqsMessage) {
    return new SimpleBasicMessage(sqsMessage.getBody(), sqsMessage.getMessageId(), sqsMessage.getReceiptHandle());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:5,代码来源:SqsBasicMessageQueue.java


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