How to Receive a Message from the Microsoft Azure Queue Service

Java SDK

import static java.lang.System.out;

import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.queue.CloudQueue;
import com.microsoft.azure.storage.queue.CloudQueueClient;
import com.microsoft.azure.storage.queue.CloudQueueMessage;

public final class AzureSample {

  public static void main(final String[] args) throws Exception {
    final CloudStorageAccount account = CloudStorageAccount.parse("DefaultEndpointsProtocol=https;AccountName=accountname;AccountKey=accountkey");

    final CloudQueueClient client = account.createCloudQueueClient();

    final CloudQueue queue = client.getQueueReference("samplequeue");

    final CloudQueueMessage msg = queue.retrieveMessage();

    out.println(msg.getMessageContentAsString());

    queue.deleteMessage(msg);
  }

}
Advertisements

How to Send a Message to Microsoft Azure Queue Service

Java SDK

import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.queue.CloudQueue;
import com.microsoft.azure.storage.queue.CloudQueueClient;
import com.microsoft.azure.storage.queue.CloudQueueMessage;

public final class AzureSample {

  public static void main(final String[] args) throws Exception {
    final CloudStorageAccount account = CloudStorageAccount.parse("DefaultEndpointsProtocol=https;AccountName=accountname;AccountKey=accountKey");

    final CloudQueueClient client = account.createCloudQueueClient();

    final CloudQueue queue = client.getQueueReference("samplequeue");

    queue.addMessage(new CloudQueueMessage("Simples Assim"));
  }

}

Cloud Messaging Services