如果队列中没有消息,则Worker Role会关闭

时间:2013-03-29 04:22:25

标签: c# azure azure-worker-roles

每当我尝试检查队列中是否有任何消息时,我都会得到一个“对象引用未设置为对象的实例”。我相信可能是因为我的队列过期而且已经关闭..

  

msg = this.queue.GetMessage();                       if(msg!= null)

这是我的azure模拟器错误:

Diagnostics]: Error when reading control container:Microsoft.WindowsAzure.StorageClient.StorageClientException: ERROR ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
   at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
   at Microsoft.WindowsAzure.Diagnostics.ControlChannel.GetControlContainer()
[Diagnostics]: Polling for configuration changes:System.NullReferenceException: Object reference not set to an instance of an object.

我在OnStart方法上做的是:

  

ServicePointManager.DefaultConnectionLimit = 12;

        // read storage account configuration settings
        CloudStorageAccount.SetConfigurationSettingPublisher((configName,
     

configSetter)=>               {                   configSetter(RoleEnvironment.GetConfigurationSettingValue(CONFIGNAME));               });               var storageAccount = CloudStorageAccount.FromConfigurationSetting(“DataConnectionString”);

        // initialize blob storage
        CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
        this.container = blobStorage.GetContainerReference("userpictures");

        // initialize queue storage 
        CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();
        this.queue = queueStorage.GetQueueReference("pictureminiatures");
        this.queue.CreateIfNotExist();

你能帮我看一下我做错了什么吗?

0 个答案:

没有答案