Search in sources :

Example 1 with UncheckedInterruptedException

use of io.datarouter.util.concurrent.UncheckedInterruptedException in project datarouter by hotpads.

the class BaseSqsPeekMultiOp method run.

@Override
protected final List<T> run() {
    ReceiveMessageRequest request = makeRequest();
    ReceiveMessageResult result;
    try {
        result = sqsClientManager.getAmazonSqs(clientId).receiveMessage(request);
    } catch (AbortedException e) {
        throw new UncheckedInterruptedException("", e);
    }
    List<Message> messages = result.getMessages();
    return messages.isEmpty() ? List.of() : extractDatabeans(messages);
}
Also used : ReceiveMessageRequest(com.amazonaws.services.sqs.model.ReceiveMessageRequest) Message(com.amazonaws.services.sqs.model.Message) AbortedException(com.amazonaws.AbortedException) UncheckedInterruptedException(io.datarouter.util.concurrent.UncheckedInterruptedException) ReceiveMessageResult(com.amazonaws.services.sqs.model.ReceiveMessageResult)

Example 2 with UncheckedInterruptedException

use of io.datarouter.util.concurrent.UncheckedInterruptedException in project datarouter by hotpads.

the class SqsAckOp method run.

@Override
protected Void run() {
    String handle = StringCodec.UTF_8.decode(key.getHandle());
    var deleteRequest = new DeleteMessageRequest(queueUrl, handle);
    try {
        sqsClientManager.getAmazonSqs(clientId).deleteMessage(deleteRequest);
    } catch (AbortedException e) {
        throw new UncheckedInterruptedException("", e);
    }
    return null;
}
Also used : AbortedException(com.amazonaws.AbortedException) DeleteMessageRequest(com.amazonaws.services.sqs.model.DeleteMessageRequest) UncheckedInterruptedException(io.datarouter.util.concurrent.UncheckedInterruptedException)

Example 3 with UncheckedInterruptedException

use of io.datarouter.util.concurrent.UncheckedInterruptedException in project datarouter by hotpads.

the class SqsPutOp method run.

@Override
protected Void run() {
    FieldGeneratorTool.generateAndSetValueForFieldIfNecessary(fieldInfo, databean);
    String encodedDatabean = codec.toString(databean, fielder);
    if (StringCodec.UTF_8.encode(encodedDatabean).length > BaseSqsNode.MAX_BYTES_PER_MESSAGE) {
        throw new SqsDataTooLargeException(List.of(encodedDatabean));
    }
    var request = new SendMessageRequest(queueUrl, encodedDatabean);
    try {
        sqsClientManager.getAmazonSqs(clientId).sendMessage(request);
    } catch (AbortedException e) {
        throw new UncheckedInterruptedException("", e);
    }
    return null;
}
Also used : AbortedException(com.amazonaws.AbortedException) SqsDataTooLargeException(io.datarouter.aws.sqs.SqsDataTooLargeException) UncheckedInterruptedException(io.datarouter.util.concurrent.UncheckedInterruptedException) SendMessageRequest(com.amazonaws.services.sqs.model.SendMessageRequest)

Example 4 with UncheckedInterruptedException

use of io.datarouter.util.concurrent.UncheckedInterruptedException in project datarouter by hotpads.

the class SqsGroupPutMultiOp method flush.

private void flush(List<byte[]> group) {
    if (group.isEmpty()) {
        return;
    }
    String stringGroup = codec.concatGroup(group);
    SendMessageRequest request = new SendMessageRequest(queueUrl, stringGroup);
    try {
        sqsClientManager.getAmazonSqs(clientId).sendMessage(request);
    } catch (AbortedException e) {
        throw new UncheckedInterruptedException("", e);
    }
}
Also used : AbortedException(com.amazonaws.AbortedException) UncheckedInterruptedException(io.datarouter.util.concurrent.UncheckedInterruptedException) SendMessageRequest(com.amazonaws.services.sqs.model.SendMessageRequest)

Aggregations

AbortedException (com.amazonaws.AbortedException)4 UncheckedInterruptedException (io.datarouter.util.concurrent.UncheckedInterruptedException)4 SendMessageRequest (com.amazonaws.services.sqs.model.SendMessageRequest)2 DeleteMessageRequest (com.amazonaws.services.sqs.model.DeleteMessageRequest)1 Message (com.amazonaws.services.sqs.model.Message)1 ReceiveMessageRequest (com.amazonaws.services.sqs.model.ReceiveMessageRequest)1 ReceiveMessageResult (com.amazonaws.services.sqs.model.ReceiveMessageResult)1 SqsDataTooLargeException (io.datarouter.aws.sqs.SqsDataTooLargeException)1