public void NeverEverCreatesAMessageBiggerThan256KB() { const int BufferSize = 10 * 1024; const int NumberOfMessages = 1000; var random = new Random(); var list = new List <Event>(); for (int i = 0; i < NumberOfMessages; i++) { var fatMessage = new FatMessage() { ALotOfBytes = new byte[BufferSize + random.Next(10000)] }; random.NextBytes(fatMessage.ALotOfBytes); list.Add(new Event(fatMessage)); } var batchUp = ServiceBusOperator.BatchUp(list); foreach (var batch in batchUp) { var sum = batch.Sum(x => x.Size); Assert.True(sum < 256 * 1024, "Size BIg!"); Console.WriteLine("Size => {0}", sum); } Assert.Equal(NumberOfMessages, batchUp.Sum(x => x.Count)); }
static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: BeeHive.Azure.Pusher <azure service bus namespace> <topic name> <file name>"); return; } try { var serviceBusOperator = new ServiceBusOperator(args[0]); serviceBusOperator.PushAsync(new Event() { Body = File.ReadAllText(args[2]), ContentType = "application/json", EventType = "Standard", QueueName = QueueName.FromTopicName(args[1]).ToString(), Timestamp = DateTimeOffset.Now }).Wait(); Console.WriteLine("Message was sent successfully"); } catch (Exception e) { Console.WriteLine("DAILED: " + e.ToString()); } }
public void TopicAndSubscriptionCreateAndSentAndReceivedForOneMinute() { var topicName = Guid.NewGuid().ToString("N"); var subName = Guid.NewGuid().ToString("N"); var topicQueueName = QueueName.FromTopicName(topicName); var queueName = QueueName.FromTopicAndSubscriptionName(topicName, subName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); serviceBusOperator.CreateQueueAsync(topicQueueName).Wait(); serviceBusOperator.CreateQueueAsync(queueName).Wait(); serviceBusOperator.PushAsync(new Event("chashm") { QueueName = topicQueueName.ToString() }).Wait(); var pollerResult = serviceBusOperator.NextAsync(queueName).Result; var cancellationTokenSource = new CancellationTokenSource(); serviceBusOperator.KeepExtendingLeaseAsync(pollerResult.PollingResult, TimeSpan.FromSeconds(10), cancellationTokenSource.Token); Thread.Sleep(35000); cancellationTokenSource.Cancel(); serviceBusOperator.CommitAsync(pollerResult.PollingResult); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait(); }
static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: BeeHive.Azure.Pusher <azure service bus namespace> <topic name> <file name>"); return; } try { var serviceBusOperator = new ServiceBusOperator(args[0]); serviceBusOperator.PushAsync(new Event() { Body = File.ReadAllText(args[2]), ContentType = "application/json", EventType = "Standard", QueueName = QueueName.FromTopicName(args[1]).ToString(), Timestamp = DateTimeOffset.Now }).Wait(); Console.WriteLine("Message was sent successfully"); } catch (Exception e) { Console.WriteLine("DAILED: " + e.ToString()); } }
public async Task TopicAndSubscriptionCreateAndSentBatch() { var topicName = Guid.NewGuid().ToString("N"); var subName = Guid.NewGuid().ToString("N"); var topicQueueName = QueueName.FromTopicName(topicName); var queueName = QueueName.FromTopicAndSubscriptionName(topicName, subName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); await serviceBusOperator.CreateQueueAsync(topicQueueName); await serviceBusOperator.CreateQueueAsync(queueName); await serviceBusOperator.PushBatchAsync(new[] { new Event("chashm") { QueueName = topicQueueName.ToString() }, new Event("chashm") { QueueName = topicQueueName.ToString() } }); await serviceBusOperator.DeleteQueueAsync(queueName); await serviceBusOperator.DeleteQueueAsync(topicQueueName); }
public void TopicCreateAndExists() { var topicName = Guid.NewGuid().ToString("N"); var queueName = QueueName.FromTopicName(topicName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result); serviceBusOperator.CreateQueueAsync(queueName).Wait(); Assert.True(serviceBusOperator.QueueExistsAsync(queueName).Result); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result); }
public void TopicCreateAndExists() { var topicName = Guid.NewGuid().ToString("N"); var queueName = QueueName.FromTopicName(topicName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result); serviceBusOperator.CreateQueueAsync(queueName).Wait(); Assert.True(serviceBusOperator.QueueExistsAsync(queueName).Result); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result); }
public async Task TopicCreateAndExists() { var topicName = Guid.NewGuid().ToString("N"); var queueName = QueueName.FromTopicName(topicName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); Assert.False(await serviceBusOperator.QueueExistsAsync(queueName)); await serviceBusOperator.CreateQueueAsync(queueName); Assert.True(await serviceBusOperator.QueueExistsAsync(queueName)); await serviceBusOperator.DeleteQueueAsync(queueName); Assert.False(await serviceBusOperator.QueueExistsAsync(queueName)); }
public void TopicAndSubscriptionCreateAndSent() { var topicName = Guid.NewGuid().ToString("N"); var subName = Guid.NewGuid().ToString("N"); var topicQueueName = QueueName.FromTopicName(topicName); var queueName = QueueName.FromTopicAndSubscriptionName(topicName, subName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); serviceBusOperator.CreateQueueAsync(topicQueueName).Wait(); serviceBusOperator.CreateQueueAsync(queueName).Wait(); serviceBusOperator.PushAsync(new Event("chashm") { QueueName = topicQueueName.ToString() }).Wait(); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait(); }
public void TopicAndSubscriptionCreateAndSent() { var topicName = Guid.NewGuid().ToString("N"); var subName = Guid.NewGuid().ToString("N"); var topicQueueName = QueueName.FromTopicName(topicName); var queueName = QueueName.FromTopicAndSubscriptionName(topicName, subName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); serviceBusOperator.CreateQueueAsync(topicQueueName).Wait(); serviceBusOperator.CreateQueueAsync(queueName).Wait(); serviceBusOperator.PushAsync(new Event("chashm") { QueueName = topicQueueName.ToString() }).Wait(); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait(); }
public void TopicAndSubscriptionCreateAndSentAndReceivedForOneMinute() { var topicName = Guid.NewGuid().ToString("N"); var subName = Guid.NewGuid().ToString("N"); var topicQueueName = QueueName.FromTopicName(topicName); var queueName = QueueName.FromTopicAndSubscriptionName(topicName, subName); var serviceBusOperator = new ServiceBusOperator(ConnectionString); serviceBusOperator.CreateQueueAsync(topicQueueName).Wait(); serviceBusOperator.CreateQueueAsync(queueName).Wait(); serviceBusOperator.PushAsync(new Event("chashm") { QueueName = topicQueueName.ToString() }).Wait(); var pollerResult = serviceBusOperator.NextAsync(queueName).Result; var cancellationTokenSource = new CancellationTokenSource(); serviceBusOperator.KeepExtendingLeaseAsync(pollerResult.PollingResult, TimeSpan.FromSeconds(10), cancellationTokenSource.Token); Thread.Sleep(35000); cancellationTokenSource.Cancel(); serviceBusOperator.CommitAsync(pollerResult.PollingResult); serviceBusOperator.DeleteQueueAsync(queueName).Wait(); serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait(); }