private List<String> delete(List<Message> messages) { if (messages == null || messages.isEmpty()) { return null; } DeleteMessageBatchRequest batch = new DeleteMessageBatchRequest().withQueueUrl(queueURL); List<DeleteMessageBatchRequestEntry> entries = batch.getEntries(); messages.forEach(m -> entries.add(new DeleteMessageBatchRequestEntry().withId(m.getId()).withReceiptHandle(m.getReceipt()))); DeleteMessageBatchResult result = client.deleteMessageBatch(batch); List<String> failures = result.getFailed().stream() .map(BatchResultErrorEntry::getId) .collect(Collectors.toList()); logger.debug("Failed to delete messages from queue: {}: {}", queueName, failures); return failures; } }
public DeleteMessageBatchRequestEntry unmarshall(StaxUnmarshallerContext context) throws Exception { DeleteMessageBatchRequestEntry deleteMessageBatchRequestEntry = new DeleteMessageBatchRequestEntry(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return deleteMessageBatchRequestEntry; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Id", targetDepth)) { deleteMessageBatchRequestEntry.setId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("ReceiptHandle", targetDepth)) { deleteMessageBatchRequestEntry.setReceiptHandle(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return deleteMessageBatchRequestEntry; } } } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode()); hashCode = prime * hashCode + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode()); return hashCode; }
/** * Constructs a new DeleteMessageBatchRequestEntry object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param id * An identifier for this particular receipt handle. This is used to communicate the result.</p> <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * @param receiptHandle * A receipt handle. */ public DeleteMessageBatchRequestEntry(String id, String receiptHandle) { setId(id); setReceiptHandle(receiptHandle); }
@Override public void commitMessages( final List<LegacyQueueMessage> queueMessages ) { String url = getReadQueue().getUrl(); if ( logger.isTraceEnabled() ) { logger.trace( "Commit messages {} to queue {}", queueMessages.size(), url ); } List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>(); for ( LegacyQueueMessage message : queueMessages ) { entries.add( new DeleteMessageBatchRequestEntry( message.getMessageId(), message.getHandle() ) ); } DeleteMessageBatchRequest request = new DeleteMessageBatchRequest( url, entries ); DeleteMessageBatchResult result = sqs.deleteMessageBatch( request ); boolean successful = result.getFailed().size() <= 0; logger.debug("commitMessages: successful: {}, failed: {}", result.getSuccessful().size(), result.getFailed().size()); if ( !successful ) { for ( BatchResultErrorEntry failed : result.getFailed() ) { logger.error( "Commit failed reason: {} messages id: {}", failed.getMessage(), failed.getId() ); } } }
String receiptHandle = entry.getReceiptHandle(); String origReceiptHandle = receiptHandle; if (isS3ReceiptHandle(receiptHandle)) { origReceiptHandle = getOrigReceiptHandle(receiptHandle); entry.setReceiptHandle(origReceiptHandle);
/** * <p> * A receipt handle. * </p> * * @param receiptHandle * A receipt handle. * @return Returns a reference to this object so that method calls can be chained together. */ public DeleteMessageBatchRequestEntry withReceiptHandle(String receiptHandle) { setReceiptHandle(receiptHandle); return this; }
/** * <p> * An identifier for this particular receipt handle. This is used to communicate the result. * </p> * <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * </note> * * @param id * An identifier for this particular receipt handle. This is used to communicate the result.</p> <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * @return Returns a reference to this object so that method calls can be chained together. */ public DeleteMessageBatchRequestEntry withId(String id) { setId(id); return this; }
DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry( Integer.toString(batchId), receiptHandle); deleteMessageBatchRequestEntries.add(entry);
/** * Constructs a new DeleteMessageBatchRequestEntry object. Callers should * use the setter or fluent setter (with...) methods to initialize any * additional object members. * * @param id <p> * An identifier for this particular receipt handle. This is used * to communicate the result. Note that the <code>Id</code>s of a * batch request need to be unique within the request. * </p> * @param receiptHandle <p> * A receipt handle. * </p> */ public DeleteMessageBatchRequestEntry(String id, String receiptHandle) { setId(id); setReceiptHandle(receiptHandle); }
/** * <p> * A receipt handle. * </p> * * @param receiptHandle * A receipt handle. * @return Returns a reference to this object so that method calls can be chained together. */ public DeleteMessageBatchRequestEntry withReceiptHandle(String receiptHandle) { setReceiptHandle(receiptHandle); return this; }
/** * <p> * An identifier for this particular receipt handle. This is used to communicate the result. * </p> * <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * </note> * * @param id * An identifier for this particular receipt handle. This is used to communicate the result.</p> <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * @return Returns a reference to this object so that method calls can be chained together. */ public DeleteMessageBatchRequestEntry withId(String id) { setId(id); return this; }
requests.size()); for (int i = 0, n = requests.size(); i < n; i++) { entries.add(new DeleteMessageBatchRequestEntry().withId(Integer.toString(i)).withReceiptHandle( requests.get(i).getReceiptHandle()));
final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(); String receiptHandle = context.getProperty(RECEIPT_HANDLE).evaluateAttributeExpressions(flowFile).getValue(); entry.setReceiptHandle(receiptHandle); String entryId = flowFile.getAttribute(CoreAttributes.UUID.key()); entry.setId(entryId); entries.add(entry);
DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry( Integer.toString(batchId), receiptHandle); deleteMessageBatchRequestEntries.add(entry);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DeleteMessageBatchRequestEntry == false) return false; DeleteMessageBatchRequestEntry other = (DeleteMessageBatchRequestEntry) obj; if (other.getId() == null ^ this.getId() == null) return false; if (other.getId() != null && other.getId().equals(this.getId()) == false) return false; if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == null) return false; if (other.getReceiptHandle() != null && other.getReceiptHandle().equals(this.getReceiptHandle()) == false) return false; return true; }
/** * Constructs a new DeleteMessageBatchRequestEntry object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param id * An identifier for this particular receipt handle. This is used to communicate the result.</p> <note> * <p> * The <code>Id</code>s of a batch request need to be unique within a request * </p> * @param receiptHandle * A receipt handle. */ public DeleteMessageBatchRequestEntry(String id, String receiptHandle) { setId(id); setReceiptHandle(receiptHandle); }
requests.size()); for (int i = 0, n = requests.size(); i < n; i++) entries.add(new DeleteMessageBatchRequestEntry().withId( Integer.toString(i)).withReceiptHandle( requests.get(i).getReceiptHandle())); batchRequest.setEntries(entries);
final List<DeleteMessageBatchRequestEntry> deleteRequestEntries = new ArrayList<>(); for (final Message message : messages) { final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(); entry.setId(message.getMessageId()); entry.setReceiptHandle(message.getReceiptHandle()); deleteRequestEntries.add(entry);
for (Message msg : list) { messages.add(msg.getBody()); del.add(new DeleteMessageBatchRequestEntry(msg.getMessageId(), msg.getReceiptHandle()));