Search in sources :

Example 1 with QueueMessage

use of com.microsoft.tooling.msservices.model.storage.QueueMessage in project azure-tools-for-java by Microsoft.

the class QueueFileEditor method viewMessageText.

private void viewMessageText() {
    QueueMessage message = (QueueMessage) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    ViewMessageForm viewMessageForm = new ViewMessageForm(PluginUtil.getParentShell(), message.getContent());
    viewMessageForm.open();
}
Also used : QueueMessage(com.microsoft.tooling.msservices.model.storage.QueueMessage) ViewMessageForm(com.microsoft.azuretools.azureexplorer.forms.ViewMessageForm)

Example 2 with QueueMessage

use of com.microsoft.tooling.msservices.model.storage.QueueMessage in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method dequeueFirstQueueMessage.

@NotNull
public QueueMessage dequeueFirstQueueMessage(@NotNull StorageAccount storageAccount, @NotNull Queue queue) throws AzureCmdException {
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        String queueName = queue.getName();
        CloudQueue cloudQueue = client.getQueueReference(queueName);
        CloudQueueMessage cqm = cloudQueue.retrieveMessage();
        String id = "";
        String content = "";
        Calendar insertionTime = new GregorianCalendar();
        Calendar expirationTime = new GregorianCalendar();
        int dequeueCount = 0;
        if (cqm != null) {
            id = Strings.nullToEmpty(cqm.getId());
            content = Strings.nullToEmpty(cqm.getMessageContentAsString());
            if (cqm.getInsertionTime() != null) {
                insertionTime.setTime(cqm.getInsertionTime());
            }
            if (cqm.getExpirationTime() != null) {
                expirationTime.setTime(cqm.getExpirationTime());
            }
            dequeueCount = cqm.getDequeueCount();
        }
        QueueMessage queueMessage = new QueueMessage(id, queueName, content, insertionTime, expirationTime, dequeueCount);
        if (cqm != null) {
            cloudQueue.deleteMessage(cqm);
        }
        return queueMessage;
    } catch (Throwable t) {
        throw new AzureCmdException("Error dequeuing the first Queue Message", t);
    }
}
Also used : QueueMessage(com.microsoft.tooling.msservices.model.storage.QueueMessage) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 3 with QueueMessage

use of com.microsoft.tooling.msservices.model.storage.QueueMessage in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getQueueMessages.

@NotNull
public List<QueueMessage> getQueueMessages(@NotNull StorageAccount storageAccount, @NotNull Queue queue) throws AzureCmdException {
    List<QueueMessage> qmList = new ArrayList<QueueMessage>();
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        String queueName = queue.getName();
        CloudQueue cloudQueue = client.getQueueReference(queueName);
        for (CloudQueueMessage cqm : cloudQueue.peekMessages(32)) {
            String id = Strings.nullToEmpty(cqm.getId());
            String content = Strings.nullToEmpty(cqm.getMessageContentAsString());
            Calendar insertionTime = new GregorianCalendar();
            if (cqm.getInsertionTime() != null) {
                insertionTime.setTime(cqm.getInsertionTime());
            }
            Calendar expirationTime = new GregorianCalendar();
            if (cqm.getExpirationTime() != null) {
                expirationTime.setTime(cqm.getExpirationTime());
            }
            int dequeueCount = cqm.getDequeueCount();
            qmList.add(new QueueMessage(id, queueName, content, insertionTime, expirationTime, dequeueCount));
        }
        return qmList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Queue Message list", t);
    }
}
Also used : QueueMessage(com.microsoft.tooling.msservices.model.storage.QueueMessage) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueueMessage(com.microsoft.azure.storage.queue.CloudQueueMessage) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Aggregations

QueueMessage (com.microsoft.tooling.msservices.model.storage.QueueMessage)3 CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)2 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)2 CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)2 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)2 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)2 ViewMessageForm (com.microsoft.azuretools.azureexplorer.forms.ViewMessageForm)1