SQSTaskQueue implements TaskQueue { protected Task marshallTask(Message msg) { Properties props = new Properties(); Task task = null; try { props.load(new StringReader(msg.getBody())); if (props.containsKey(Task.KEY_TYPE)) { task = new Task(); for (final String key : props.stringPropertyNames()) { if (key.equals(Task.KEY_TYPE)) { task.setType(Task.Type.valueOf(props.getProperty(key))); } else { task.addProperty(key, props.getProperty(key)); } } task.addProperty(MsgProp.MSG_ID.name(), msg.getMessageId()); task.addProperty(MsgProp.RECEIPT_HANDLE.name(), msg.getReceiptHandle()); } else { log.error("SQS message from queue: " + queueName + ", queueUrl: " + queueUrl + " does not contain a 'task type'"); } } catch (IOException ioe) { log.error("Error creating Task", ioe); } return task; } 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 testMarshallTask() { setupSQSClient(); replayAll(); createSubject(); String msgId = "test-msg-id-1234"; String receiptHandle = "test-msg-rcpt-handle-1234"; Message msg = new Message(); msg.setMessageId(msgId); msg.setReceiptHandle(receiptHandle); msg.setBody(Task.KEY_TYPE + "=" + Task.Type.DUP.name() + "\n" + "key1=value1\nkey2=value2\nkey3=value3"); Task task = queue.marshallTask(msg); assertThat(task.getProperty(SQSTaskQueue.MsgProp.MSG_ID.name()), is(equalTo(msgId))); assertThat(task.getProperty(SQSTaskQueue.MsgProp.RECEIPT_HANDLE.name()), is(equalTo(receiptHandle))); assertThat(task.getType(), is(equalTo(Task.Type.DUP))); assertThat(task.getProperty("key1"), is(equalTo("value1"))); assertThat(task.getProperty("key2"), is(equalTo("value2"))); assertThat(task.getProperty("key3"), is(equalTo("value3"))); }