public async static Task ExamplePulser([TimerTrigger("0 1/10 * * * *")] TimerInfo info, ILogger log) { await GetOperator().PushAsync(new Event("does not matter") { QueueName = QueueName.FromTopicName("PulseTopic").ToString() }); }
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 FromTopicName() { var name = QueueName.FromTopicName("Ali"); Assert.True(name.IsTopic); Assert.False(name.IsSimpleQueue); }
private async Task DoScheduleAsync(PeckSource source) { var oldTimestamp = source.Timestamp; try { await _eventQueueOperator.PushAsync(new Event(new PeckSourceScheduled() { Source = source }) { QueueName = QueueName.FromTopicName("PeckSourceScheduled").ToString() }); source.LastOffset = DateTimeOffset.UtcNow; await _table.ExecuteAsync(TableOperation.InsertOrMerge(source)); } catch (Exception e) { source.LastOffset = oldTimestamp; TheTrace.TraceError("Error scheduling source {0} : {1}", source.Name, e); try { _table.Execute(TableOperation.InsertOrMerge(source)); } catch (Exception ex) { TheTrace.TraceError("Error saving error (!) in table. Source {0} : {1}", source.Name, ex); } } }
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(); }
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 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 SimpleAutoPulser(TimeSpan interval, params string[] eventTypes) { if (eventTypes.Length == 0) { throw new ArgumentOutOfRangeException("eventTypes", "At least one event type needs to be passed in."); } _poller = new Poller(new FixedInterval(interval), () => { if (PulseGenerated != null) { PulseGenerated(this, eventTypes.Select(x => new Event(string.Empty) { EventType = QueueName.FromTopicName(x).ToString(), QueueName = QueueName.FromTopicName(x).ToString() }).ToArray()); } return(false); }); }
public async Task CreateQueueAsync(QueueName name) { if (name.IsSimpleQueue) { await _lazyNamespaceManager.Value.CreateQueueAsync(name.TopicName); } else { if (name.IsTopic) { await _lazyNamespaceManager.Value.CreateTopicAsync(name.TopicName); } else { await this.SetupQueueAsync(QueueName.FromTopicName(name.TopicName)); await _lazyNamespaceManager.Value.CreateSubscriptionAsync(name.TopicName, name.SubscriptionName); } } }