Search in sources :

Example 6 with CloudQueueMessage

use of com.microsoft.azure.storage.queue.CloudQueueMessage in project camel by apache.

the class QueueServiceProducer method updateMessage.

private void updateMessage(Exchange exchange) throws Exception {
    CloudQueue client = QueueServiceUtil.createQueueClient(getConfiguration());
    QueueServiceRequestOptions opts = QueueServiceUtil.getRequestOptions(exchange);
    CloudQueueMessage message = getCloudQueueMessage(exchange);
    LOG.trace("Updating the message in the queue [{}] from exchange [{}]...", getConfiguration().getQueueName(), exchange);
    EnumSet<MessageUpdateFields> fields = null;
    Object fieldsObject = exchange.getIn().getHeader(QueueServiceConstants.MESSAGE_UPDATE_FIELDS);
    if (fieldsObject instanceof EnumSet) {
        @SuppressWarnings("unchecked") EnumSet<MessageUpdateFields> theFields = (EnumSet<MessageUpdateFields>) fieldsObject;
        fields = theFields;
    } else if (fieldsObject instanceof MessageUpdateFields) {
        fields = EnumSet.of((MessageUpdateFields) fieldsObject);
    }
    client.updateMessage(message, getConfiguration().getMessageVisibilityDelay(), fields, opts.getRequestOpts(), opts.getOpContext());
}
Also used : EnumSet(java.util.EnumSet) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) MessageUpdateFields(com.microsoft.azure.storage.queue.MessageUpdateFields) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue)

Example 7 with CloudQueueMessage

use of com.microsoft.azure.storage.queue.CloudQueueMessage in project camel by apache.

the class QueueServiceProducer method getCloudQueueMessage.

private CloudQueueMessage getCloudQueueMessage(Exchange exchange) throws Exception {
    Object body = exchange.getIn().getMandatoryBody();
    CloudQueueMessage message = null;
    if (body instanceof CloudQueueMessage) {
        message = (CloudQueueMessage) body;
    } else if (body instanceof String) {
        message = new CloudQueueMessage((String) body);
    }
    if (message == null) {
        throw new IllegalArgumentException("Unsupported queue message type:" + body.getClass().getName());
    }
    return message;
}
Also used : CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage)

Example 8 with CloudQueueMessage

use of com.microsoft.azure.storage.queue.CloudQueueMessage in project camel by apache.

the class QueueServiceProducer method deleteMessage.

private void deleteMessage(Exchange exchange) throws Exception {
    LOG.trace("Deleting the message from the queue [{}] from exchange [{}]...", getConfiguration().getQueueName(), exchange);
    CloudQueue client = QueueServiceUtil.createQueueClient(getConfiguration());
    QueueServiceRequestOptions opts = QueueServiceUtil.getRequestOptions(exchange);
    CloudQueueMessage message = getCloudQueueMessage(exchange);
    client.deleteMessage(message, opts.getRequestOpts(), opts.getOpContext());
}
Also used : CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue)

Example 9 with CloudQueueMessage

use of com.microsoft.azure.storage.queue.CloudQueueMessage in project camel by apache.

the class QueueServiceUtil method retrieveMessage.

public static void retrieveMessage(Exchange exchange, QueueServiceConfiguration cfg) throws Exception {
    CloudQueue client = createQueueClient(cfg);
    QueueServiceRequestOptions opts = getRequestOptions(exchange);
    CloudQueueMessage message = client.retrieveMessage(cfg.getMessageVisibilityDelay(), opts.getRequestOpts(), opts.getOpContext());
    ExchangeUtil.getMessageForResponse(exchange).setBody(message);
}
Also used : CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue)

Aggregations

CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)9 CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)8 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)3 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)3 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)2 QueueMessage (com.microsoft.tooling.msservices.model.storage.QueueMessage)2 MessageUpdateFields (com.microsoft.azure.storage.queue.MessageUpdateFields)1 EnumSet (java.util.EnumSet)1