本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Queue.CloudQueue类的典型用法代码示例。如果您正苦于以下问题:C# CloudQueue类的具体用法?C# CloudQueue怎么用?C# CloudQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudQueue类属于Microsoft.WindowsAzure.Storage.Queue命名空间,在下文中一共展示了CloudQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: configureQueue
protected virtual void configureQueue(CloudStorageAccount storageAccount)
{
// Create the queue client
this.queueClient = storageAccount.CreateCloudQueueClient();
this.queue = createQueue(this.queueClient, this.queueName);
}
示例2: RequestSasToken
static string RequestSasToken(CloudQueue queue)
{
// Omitting any authentication code since this is beyond the scope of
// this sample code
// creating a shared access policy that expires in 1 day.
// No start time is specified, which means that the token is valid immediately.
// The policy specifies full permissions.
SharedAccessQueuePolicy policy = new SharedAccessQueuePolicy()
{
SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
SharedAccessExpiryTime = DateTime.UtcNow.AddDays(1.0),
Permissions = SharedAccessQueuePermissions.Add |
SharedAccessQueuePermissions.Read |
SharedAccessQueuePermissions.Update |
SharedAccessQueuePermissions.ProcessMessages
};
// Generate the SAS token. No access policy identifier is used which
// makes it a non-revocable token
// limiting the table SAS access to only the request customer's id
string sasToken = queue.GetSharedAccessSignature(policy);
return sasToken;
}
示例3: QueueListenerTests
public QueueListenerTests()
{
CloudQueue queue = new CloudQueue(new Uri("https://test.queue.core.windows.net/testqueue"));
Mock<IStorageQueue> mockQueue = new Mock<IStorageQueue>(MockBehavior.Strict);
mockQueue.Setup(p => p.SdkObject).Returns(queue);
_mockTriggerExecutor = new Mock<ITriggerExecutor<IStorageQueueMessage>>(MockBehavior.Strict);
Mock<IDelayStrategy> mockDelayStrategy = new Mock<IDelayStrategy>(MockBehavior.Strict);
Mock<IBackgroundExceptionDispatcher> mockExceptionDispatcher = new Mock<IBackgroundExceptionDispatcher>(MockBehavior.Strict);
TextWriter log = new StringWriter();
Mock<IQueueProcessorFactory> mockQueueProcessorFactory = new Mock<IQueueProcessorFactory>(MockBehavior.Strict);
JobHostQueuesConfiguration queuesConfig = new JobHostQueuesConfiguration();
QueueProcessorFactoryContext context = new QueueProcessorFactoryContext(queue, log, queuesConfig);
_mockQueueProcessor = new Mock<QueueProcessor>(MockBehavior.Strict, context);
JobHostQueuesConfiguration queueConfig = new JobHostQueuesConfiguration
{
MaxDequeueCount = 5,
QueueProcessorFactory = mockQueueProcessorFactory.Object
};
mockQueueProcessorFactory.Setup(p => p.Create(It.IsAny<QueueProcessorFactoryContext>())).Returns(_mockQueueProcessor.Object);
_listener = new QueueListener(mockQueue.Object, null, _mockTriggerExecutor.Object, mockDelayStrategy.Object, mockExceptionDispatcher.Object, log, null, queueConfig);
CloudQueueMessage cloudMessage = new CloudQueueMessage("TestMessage");
_storageMessage = new StorageQueueMessage(cloudMessage);
}
示例4: InitQueue
private void InitQueue()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
queue = queueClient.GetQueueReference("jobqueue");
queue.CreateIfNotExists();
}
示例5: QueueProcessorFactoryContext
/// <summary>
/// Constructs a new instance
/// </summary>
/// <param name="queue">The <see cref="CloudQueue"/> the <see cref="QueueProcessor"/> will operate on.</param>
/// <param name="trace">The <see cref="TraceWriter"/> to write to.</param>
/// <param name="queueConfiguration">The queue configuration.</param>
/// <param name="poisonQueue">The queue to move messages to when unable to process a message after the maximum dequeue count has been exceeded. May be null.</param>
internal QueueProcessorFactoryContext(CloudQueue queue, TraceWriter trace, IQueueConfiguration queueConfiguration, CloudQueue poisonQueue = null)
: this(queue, trace, poisonQueue)
{
BatchSize = queueConfiguration.BatchSize;
MaxDequeueCount = queueConfiguration.MaxDequeueCount;
NewBatchThreshold = queueConfiguration.NewBatchThreshold;
}
示例6: AzureQueueController
public AzureQueueController()
{
var credentials = new StorageCredentials(ConfigurationManager.AppSettings["AzureAccountName"], ConfigurationManager.AppSettings["AzureKeyValue"]);
var azureTableUri = new Uri("https://" + ConfigurationManager.AppSettings["AzureAccountName"] + ".queue.core.windows.net");
var client = new CloudQueueClient(azureTableUri, credentials);
_queue = client.GetQueueReference(QueueName);
}
示例7: StorageQueueViewModel
public StorageQueueViewModel(CloudQueue queue)
{
if (queue == null)
throw new ArgumentNullException(nameof(queue));
_queue = queue;
}
示例8: OnStart
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount;
// Read storage account configuration settings
ConfigureDiagnostics();
Trace.TraceInformation("Initializing storage account in worker role B");
var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
// Initialize queue storage
Trace.TraceInformation("Creating queue client.");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
sendEmailQueue = queueClient.GetQueueReference("azuremailqueue");
subscribeQueue = queueClient.GetQueueReference("azuremailsubscribequeue");
// Initialize blob storage
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference("azuremailblobcontainer");
// Initialize table storage
var tableClient = storageAccount.CreateCloudTableClient();
mailingListTable = tableClient.GetTableReference("mailinglist");
messageTable = tableClient.GetTableReference("message");
messagearchiveTable = tableClient.GetTableReference("messagearchive");
Trace.TraceInformation("WorkerB: Creating blob container, queue, tables, if they don't exist.");
blobContainer.CreateIfNotExists();
sendEmailQueue.CreateIfNotExists();
subscribeQueue.CreateIfNotExists();
this.messageTable.CreateIfNotExists();
this.mailingListTable.CreateIfNotExists();
this.messagearchiveTable.CreateIfNotExists();
return base.OnStart();
}
示例9: OnStart
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount;
ConfigureDiagnostics();
// Read storage account configuration settings
Trace.TraceInformation("Initializing storage account in WorkerC");
var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(
"StorageConnectionString"
));
// Initialize queue storage
Trace.TraceInformation("Creating queue client in WorkerC");
var queueClient = storageAccount.CreateCloudQueueClient();
subscribeQueue = queueClient.GetQueueReference("subscribequeue");
// Initialize table storage
Trace.TraceInformation("Creating table client in WorkerC");
var tableClient = storageAccount.CreateCloudTableClient();
subscribersTable = tableClient.GetTableReference("Subscribers");
Trace.TraceInformation("WorkerC: Creating blob container, queue, tables, if they don't exist.");
subscribeQueue.CreateIfNotExists();
subscribersTable.CreateIfNotExists();
return base.OnStart();
}
示例10: FakeStorageQueue
public FakeStorageQueue(MemoryQueueStore store, string queueName, IStorageQueueClient parent)
{
_store = store;
_queueName = queueName;
_parent = parent;
_sdkObject = new CloudQueue(new Uri("http://localhost/" + queueName));
}
示例11: ProcessRequestAsync
public static async Task ProcessRequestAsync(HttpContext Context, string Action) {
var form = Context.Request.Form;
Context.Response.ContentType = "text/javascript";
switch (Action) {
case Forms.TakeThePledge.Action.Form:
var businessName = form[Forms.TakeThePledge.Keys.BusinessName];
var address = form[Forms.TakeThePledge.Keys.Address];
var manager = form[Forms.TakeThePledge.Keys.OwnerManagerName];
var phoneNumber = form[Forms.TakeThePledge.Keys.PhoneNumber];
var email = form[Forms.TakeThePledge.Keys.Email];
var website = form[Forms.TakeThePledge.Keys.Website];
string message = $"Business Name: {businessName}\r\nAddress: {address}\r\nOwner/Manager: {manager}\r\nPhone Number: {phoneNumber}\r\nEmail: {email}\r\nWebsite: {website}";
try {
var e = new Site.Email() { To = Application.TakeThePledge.Form.EmailTo, Subject = "New Business Took Bag Free Portsmouth Pledge", Body = message };
if (_queue == null) {
_queue = CloudStorageAccount.Parse($"DefaultEndpointsProtocol=https;AccountName={Application.Queue.Name};AccountKey={Application.Queue.Key}").CreateCloudQueueClient().GetQueueReference(Application.Queue.Name);
}
await _queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(e)));
await Context.Response.WriteAsync(Response.Substitute(Forms.TakeThePledge.HtmlID.FormContainer, "<div class=\"tac blue\">Thanks! Your information has been received and you'll be contacted shortly.</div>"));
} catch {
await Context.Response.WriteAsync(Response.Substitute(Forms.TakeThePledge.HtmlID.FormContainer, $"<div class=\"tac blue\">Sorry, there was an error processing the form.</div>"));
}
break;
}
}
示例12: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections.
ServicePointManager.DefaultConnectionLimit = 12;
// Read database connection string and open database.
var dbConnString = CloudConfigurationManager.GetSetting("TCWAdminPortalDbConnectionString");
_dbContext = new TCWAdminContext(dbConnString);
// Open storage account using credentials from .cscfg file.
var storageAccount = CloudStorageAccount.Parse
(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
Trace.TraceInformation("Creating images blob container");
var blobClient = storageAccount.CreateCloudBlobClient();
_imagesBlobContainer = blobClient.GetContainerReference("images");
if (_imagesBlobContainer.CreateIfNotExists())
{
// Enable public access on the newly created "images" container.
_imagesBlobContainer.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
Trace.TraceInformation("Creating images queue");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
_imagesQueue = queueClient.GetQueueReference("images");
_imagesQueue.CreateIfNotExists();
Trace.TraceInformation("Storage initialized");
return base.OnStart();
}
示例13: getQueueLength
protected static int getQueueLength(CloudQueue queue)
{
queue.FetchAttributes();
var messageCount = queue.ApproximateMessageCount;
return messageCount ?? 0;
}
示例14: Setup
public void Setup()
{
client = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
client.ServerTimeout = TimeSpan.FromSeconds(10);
nativeQueue = client.GetQueueReference(QueueName);
nativeQueue.CreateIfNotExists();
nativeQueue.Clear();
sender = new AzureMessageQueueSender
{
Client = client,
MessageSerializer = new JsonMessageSerializer(new MessageMapper())
};
sender.Init(QueueName, true);
receiver = new AzureMessageQueueReceiver
{
Client = client,
MessageSerializer = new JsonMessageSerializer(new MessageMapper()),
};
receiver.Init(QueueName, true);
}
示例15: Crawler
public Crawler()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
table = tableClient.GetTableReference("crawlertable");
table.CreateIfNotExists();
datatable = tableClient.GetTableReference("datatable");
datatable.CreateIfNotExists();
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
urlQueue = queueClient.GetQueueReference("urlqueue");
urlQueue.CreateIfNotExists();
adminQueue = queueClient.GetQueueReference("adminqueue");
adminQueue.CreateIfNotExists();
alreadyVisitedUrls = new HashSet<String>();
disallowedUrls = new HashSet<String>();
errorUrls = new HashSet<String>();
tableSize = 0;
totalUrls = 0;
counter = 1;
compareDate = DateTime.ParseExact("2015-04-01", "yyyy-MM-dd", CultureInfo.InvariantCulture);
//Regex to check for valid html document
rgx = new Regex(@"^[a-zA-Z0-9\-]+.?(htm|html)?$");
}