當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。