本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudQueueMessage类的典型用法代码示例。如果您正苦于以下问题:C# CloudQueueMessage类的具体用法?C# CloudQueueMessage怎么用?C# CloudQueueMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudQueueMessage类属于Microsoft.WindowsAzure.StorageClient命名空间,在下文中一共展示了CloudQueueMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAndGetMessageReference
public void SetAndGetMessageReference()
{
var cloudMessage = new CloudQueueMessage("dummy");
var queueMessage = new TestAzureQueueMessage();
queueMessage.SetMessageReference(cloudMessage);
Assert.AreEqual(cloudMessage, queueMessage.GetMessageReference());
}
示例2: DeleteMessage
/// <summary>
///
/// </summary>
/// <param name="queueName"></param>
/// <param name="cloudQueueMessage"></param>
///
public static void DeleteMessage(string queueName, CloudQueueMessage cloudQueueMessage)
{
if (cloudQueueMessage != null)
{
DeleteMessage(queueName, cloudQueueMessage.Id, cloudQueueMessage.PopReceipt);
}
}
示例3: addJob
static void addJob(string UUID)
{
CloudQueue queue = queueClient.GetQueueReference("taskqueue");
queue.CreateIfNotExist();
CloudQueueMessage message = new CloudQueueMessage(UUID);
queue.AddMessage(message);
}
示例4: Send
public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
{
var outputQueue = cloudQueueClient.GetQueueReference(destinationQueueName);
using (var memoryStream = new MemoryStream())
{
var formatter = new BinaryFormatter();
var receivedTransportMessage = new ReceivedTransportMessage
{
Id = Guid.NewGuid().ToString(),
Headers = message.Headers,
Body = message.Body,
Label = message.Label,
};
formatter.Serialize(memoryStream, receivedTransportMessage);
memoryStream.Position = 0;
var cloudQueueMessage = new CloudQueueMessage(memoryStream.ToArray());
var timeToLive = GetTimeToLive(message);
if (timeToLive.HasValue)
{
outputQueue.AddMessage(cloudQueueMessage, timeToLive.Value);
}
else
{
outputQueue.AddMessage(cloudQueueMessage);
}
}
}
示例5: Index
//
// GET: /Subscription/
public ActionResult Index(string From, string To, string Body)
{
TwilioRestClient twilio;
SMSMessage text;
PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
string oldFrom = From;
try
{
From = phoneUtil.Parse(Body, "US").NationalNumber.ToString();
twilio = new TwilioRestClient("accountSid", "authToken");
text = twilio.SendSmsMessage("+YOURTWILIONUMBER", oldFrom, "You're so thoughtful. Steve will call your friend soon!");
}
catch (NumberParseException e)
{
}
string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=ACCOUNTKEY";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("messages");
queue.CreateIfNotExist();
CloudQueueMessage message = new CloudQueueMessage(From);
queue.AddMessage(message, new TimeSpan(1, 0, 0), new TimeSpan(0, 1, 0));
twilio = new TwilioRestClient("accountSid", "authToken");
text = twilio.SendSmsMessage("+YOURTWILIONUMBER", From, "Sorry you're not feeling well. You'll soon hear from Steve! If you want Steve to call a friend just send their number!");
return View();
}
示例6: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 100;
//Initialize Indexer
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));
//Initialize URL Queue
urlQueueClient = storageAccount.CreateCloudQueueClient();
urlQueue = urlQueueClient.GetQueueReference("urlqueue");
if (urlQueue.CreateIfNotExist())
{
//Add first URL to the queue
CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
urlQueue.AddMessage(firstURL);
}
//Initialize Index Queue
indexQueueClient = storageAccount.CreateCloudQueueClient();
indexQueue = indexQueueClient.GetQueueReference("indexqueue");
indexQueue.CreateIfNotExist();
//Initialize Database Blob
databaseClient = storageAccount.CreateCloudBlobClient();
databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
databaseContainer.CreateIfNotExist();
var permission = databaseContainer.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Container;
databaseContainer.SetPermissions(permission);
return base.OnStart();
}
示例7: SignButton_Click
protected void SignButton_Click(object sender, EventArgs e)
{
if (this.FileUpload1.HasFile)
{
this.InitializeStorage();
// upload the image to blob storage
string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
CloudBlockBlob blob = blobStorage.GetBlockBlobReference(uniqueBlobName);
blob.Properties.ContentType = this.FileUpload1.PostedFile.ContentType;
blob.UploadFromStream(this.FileUpload1.FileContent);
System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);
// create a new entry in table storage
GuestBookEntry entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blob.Uri.ToString(), ThumbnailUrl = blob.Uri.ToString() };
GuestBookDataSource ds = new GuestBookDataSource();
ds.AddGuestBookEntry(entry);
System.Diagnostics.Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName);
// queue a message to process the image
var queue = queueStorage.GetQueueReference("guestthumbs");
var message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri.ToString(), entry.PartitionKey, entry.RowKey));
queue.AddMessage(message);
System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);
}
this.NameTextBox.Text = string.Empty;
this.MessageTextBox.Text = string.Empty;
this.DataList1.DataBind();
}
示例8: SignButton_Click
protected void SignButton_Click( object sender, EventArgs e )
{
if ( FileUpload1.HasFile )
{
InitializeStorage( );
//Subo la imagen al Blob Storage
CloudBlobContainer container = blobStorage.GetContainerReference( "fotogolpics" );
string uniqueBlobName = string.Format( "image_{0}.jpg", Guid.NewGuid( ).ToString( ) );
CloudBlockBlob blob = container.GetBlockBlobReference( uniqueBlobName );
blob.Properties.ContentType = FileUpload1.PostedFile.ContentType;
blob.UploadFromStream( FileUpload1.FileContent );
System.Diagnostics.Trace.TraceInformation( "Uploaded image '{0}' to blob storage as '{1}'", FileUpload1.FileName, uniqueBlobName );
//Creo un nuevo registro en la tabla
FotoGolEntry entry = new FotoGolEntry( ) { GuestName = NameTextBox.Text, Message = MessageTextBox.Text, PhotoUrl = blob.Uri.ToString( ), ThumbnailUrl = blob.Uri.ToString( ) };
FotoGolEntryDataSource ds = new FotoGolEntryDataSource( );
ds.AddGuestBookEntry( entry );
System.Diagnostics.Trace.TraceInformation( "Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName );
//Pongo un mensaje en cola para que se procese
var queue = queueStorage.GetQueueReference( "fotogolthumbs" );
var message = new CloudQueueMessage( String.Format( "{0},{1},{2}", uniqueBlobName, entry.PartitionKey, entry.RowKey ) );
queue.AddMessage( message );
System.Diagnostics.Trace.TraceInformation( "Queued message to process blob '{0}'", uniqueBlobName );
}
NameTextBox.Text = "";
MessageTextBox.Text = "";
DataList1.DataBind( );
}
示例9: FromMessage
// See Figure 2 in http://msdn.microsoft.com/en-us/magazine/ee335721.aspx
public static AzureMessage FromMessage(CloudQueueMessage message)
{
byte[] buffer = message.AsBytes;
MemoryStream ms = new MemoryStream(buffer);
ms.Position = 0;
BinaryFormatter bf = new BinaryFormatter();
return (AzureMessage)bf.Deserialize(ms);
}
示例10: AddListingSearch
public void AddListingSearch(int leadSearchId )
{
var q = GetQ("listingsearch");
// Create a message and add it to the queue
var qMessage = new CloudQueueMessage(leadSearchId.ToString());
q.AddMessage(qMessage);
}
示例11: AddMessage
public void AddMessage()
{
SomeClass someObject = new SomeClass() { Action = "MonteCarloSimulation" };
Byte[] message = SomeClass.ToByte(someObject);
CloudQueueMessage cloudQueueMessage = new CloudQueueMessage(message);
cloudQueue.AddMessage(cloudQueueMessage);
}
示例12: ButtonSave_Click
protected void ButtonSave_Click(object sender, EventArgs e)
{
if (FileUploadImage.HasFiles & Page.IsValid)
{
string uniqueBobName = string.Format("{0}/funnyimage_{1}{2}", Utils.CloudBlobKey,
Guid.NewGuid().ToString(),
Path.GetExtension(FileUploadImage.FileName));
CloudBlockBlob blob = _blobClient.GetBlockBlobReference(uniqueBobName);
blob.Properties.ContentType = FileUploadImage.PostedFile.ContentType;
blob.UploadFromStream(FileUploadImage.FileContent);
FunnyAppRepository<Post> postRepository = new FunnyAppRepository<Post>();
FunnyAppRepository<Tag> tagRepository = new FunnyAppRepository<Tag>();
MembershipUser user = Membership.GetUser(Page.User.Identity.Name);
if (user != null)
{
Post post = new Post
{
PostContent = TextBoxDescription.Text,
PostTitle = TextBoxTitle.Text,
State = false,
UserId = user.ProviderUserKey.ToString()
};
string[] tags = TextBoxTag.Text.Split(';');
foreach (string tag in tags)
{
if (!string.IsNullOrEmpty(tag))
{
tagRepository.Create(new Tag()
{
PostRowKey = post.RowKey,
PostPartitionKey = post.PartitionKey,
TagName = tag,
});
tagRepository.SubmitChange();
}
}
postRepository.Create(post);
postRepository.SubmitChange();
CloudQueue queue = _queueClient.GetQueueReference(Utils.CloudQueueKey);
CloudQueueMessage message =
new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, post.PartitionKey, post.RowKey));
queue.AddMessage(message);
LabelResult.Text = "Uploaded";
}
else
{
LabelResult.Text = "Failed";
}
}
}
示例13: PutQueueMessage
public void PutQueueMessage(MessageType type, Dictionary<string, long> data)
{
System.IO.MemoryStream stream = new System.IO.MemoryStream(1024 * 64);
_formatter.Serialize(stream, data);
data.Add("Type", (long)type);
CloudQueueMessage message = new CloudQueueMessage(stream.ToArray());
queue.AddMessage(message);
}
示例14: AddMessages
public void AddMessages()
{
String content1 = "Do something";
CloudQueueMessage message1 = new CloudQueueMessage(content1);
cloudQueue.AddMessage(message1);
String content2 = "Do something else";
CloudQueueMessage message2 = new CloudQueueMessage(content2);
cloudQueue.AddMessage(message2, TimeSpan.FromDays(1.0));
}
示例15: Enqueue
public void Enqueue(ItemBase item)
{
CloudQueueMessage message;
using(var stream = new MemoryStream()){
new BinaryFormatter().Serialize(stream, item);
stream.Flush();
message = new CloudQueueMessage(stream.ToArray());
}
GetQueue().AddMessage(message);
}