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());
}
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;
}
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());
}
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);
}
Aggregations