SQSTaskQueue implements TaskQueue { @Override public void put(final Task task) { try { final String msgBody = unmarshallTask(task); new Retrier(4, 10000, 2).execute(new Retriable() { @Override public Object retry() throws Exception { sqsClient.sendMessage(new SendMessageRequest(queueUrl, msgBody)); return null; } }); log.info("SQS message successfully placed {} on queue - queue: {}", task, queueName); } catch (Exception ex) { log.error("failed to place {} on {} due to {}", task, queueName, ex.getMessage()); throw new DuraCloudRuntimeException(ex); } } SQSTaskQueue(String queueName);  SQSTaskQueue(AmazonSQS sqsClient, String queueName); @Override String getName(); @Override void put(final Task task); @Override void put(Task... tasks); @Override void put(Set<Task> tasks); @Override Set<Task> take(int maxTasks); @Override Task take(); @Override void extendVisibilityTimeout(Task task); @Override void deleteTask(Task task); @Override void deleteTasks(Set<Task> tasks); @Override void requeue(Task task); @Override Integer size(); @Override Integer sizeIncludingInvisibleAndDelayed();  }
@Test public void testPut() { setupSQSClient(); SendMessageResult result = createMock(SendMessageResult.class); expect(this.sqsClient.sendMessage(isA(SendMessageRequest.class))) .andThrow(new AmazonServiceException("failure")); expect(this.sqsClient.sendMessage(isA(SendMessageRequest.class))).andReturn(result); replayAll(); createSubject(); Task task = createSampleAuditTask(); this.queue.put(task); }
@Test public void testPutMuliple() { setupSQSClient(); SendMessageBatchResult result = createMock(SendMessageBatchResult.class); expect(this.sqsClient.sendMessageBatch(isA(SendMessageBatchRequest.class))) .andThrow(new AmazonServiceException("failure")); expect(this.sqsClient.sendMessageBatch(isA(SendMessageBatchRequest.class))).andReturn(result).times(2); replayAll(); createSubject(); Set<Task> tasks = new HashSet<>(); long time = System.currentTimeMillis(); for (int i = 0; i < 11; i++) { tasks.add(createSampleAuditTask(time + i)); } this.queue.put(tasks); }