Search in sources :

Example 1 with SendMessageResult

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);
}
Also used : HeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy) SendMessageResult(com.amazonaws.services.sqs.model.SendMessageResult) SendMessageRequest(com.amazonaws.services.sqs.model.SendMessageRequest) Before(org.junit.Before)

Example 2 with SendMessageResult

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;
}
Also used : Message(com.amazonaws.services.sqs.model.Message) SendMessageResult(com.amazonaws.services.sqs.model.SendMessageResult)

Example 3 with SendMessageResult

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());
}
Also used : Message(org.apache.camel.Message) SendMessageResult(com.amazonaws.services.sqs.model.SendMessageResult) SendMessageRequest(com.amazonaws.services.sqs.model.SendMessageRequest)

Aggregations

SendMessageResult (com.amazonaws.services.sqs.model.SendMessageResult)3 SendMessageRequest (com.amazonaws.services.sqs.model.SendMessageRequest)2 Message (com.amazonaws.services.sqs.model.Message)1 Message (org.apache.camel.Message)1 HeaderFilterStrategy (org.apache.camel.spi.HeaderFilterStrategy)1 Before (org.junit.Before)1