use of com.amazonaws.services.sqs.model.SendMessageResult in project camel by apache.
the class SqsProducerTest method setup.
@Before
public void setup() throws Exception {
underTest = new SqsProducer(sqsEndpoint);
sendMessageResult = new SendMessageResult().withMD5OfMessageBody(MESSAGE_MD5).withMessageId(MESSAGE_ID);
sqsConfiguration = new SqsConfiguration();
HeaderFilterStrategy headerFilterStrategy = new SqsHeaderFilterStrategy();
sqsConfiguration.setDelaySeconds(Integer.valueOf(0));
when(sqsEndpoint.getClient()).thenReturn(amazonSQSClient);
when(sqsEndpoint.getConfiguration()).thenReturn(sqsConfiguration);
when(amazonSQSClient.sendMessage(any(SendMessageRequest.class))).thenReturn(sendMessageResult);
when(exchange.getOut()).thenReturn(outMessage);
when(exchange.getIn()).thenReturn(inMessage);
when(exchange.getPattern()).thenReturn(ExchangePattern.InOnly);
when(inMessage.getBody(String.class)).thenReturn(SAMPLE_MESSAGE_BODY);
when(sqsEndpoint.getQueueUrl()).thenReturn(QUEUE_URL);
when(sqsEndpoint.getHeaderFilterStrategy()).thenReturn(headerFilterStrategy);
}
use of com.amazonaws.services.sqs.model.SendMessageResult in project camel by apache.
the class AmazonSQSClientMock method sendMessage.
@Override
public SendMessageResult sendMessage(SendMessageRequest sendMessageRequest) throws AmazonServiceException, AmazonClientException {
Message message = new Message();
message.setBody(sendMessageRequest.getMessageBody());
message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
message.setReceiptHandle("0NNAq8PwvXsyZkR6yu4nQ07FGxNmOBWi5zC9+4QMqJZ0DJ3gVOmjI2Gh/oFnb0IeJqy5Zc8kH4JX7GVpfjcEDjaAPSeOkXQZRcaBqt" + "4lOtyfj0kcclVV/zS7aenhfhX5Ixfgz/rHhsJwtCPPvTAdgQFGYrqaHly+etJiawiNPVc=");
synchronized (messages) {
messages.add(message);
}
SendMessageResult result = new SendMessageResult();
result.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
result.setMD5OfMessageBody("6a1559560f67c5e7a7d5d838bf0272ee");
return result;
}
use of com.amazonaws.services.sqs.model.SendMessageResult in project camel by apache.
the class SqsProducer method process.
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
SendMessageRequest request = new SendMessageRequest(getQueueUrl(), body);
request.setMessageAttributes(translateAttributes(exchange.getIn().getHeaders(), exchange));
addDelay(request, exchange);
LOG.trace("Sending request [{}] from exchange [{}]...", request, exchange);
SendMessageResult result = getClient().sendMessage(request);
LOG.trace("Received result [{}]", result);
Message message = getMessageForResponse(exchange);
message.setHeader(SqsConstants.MESSAGE_ID, result.getMessageId());
message.setHeader(SqsConstants.MD5_OF_BODY, result.getMD5OfMessageBody());
}
Aggregations