private async Task ReceiveDataFromAzure() { #if IOTHUB while (_azureIoTHubClient != null) { var message = await _azureIoTHubClient.ReceiveAsync(); if (message != null) { try { var msg = new Models.ReceivedMessage(message.GetBytes()); msg.MessageId = message.MessageId; msg.Topic = message.To; DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg)); // Received a new message, display it // We received the message, indicate IoTHub we treated it await _azureIoTHubClient.CompleteAsync(message); } catch { await _azureIoTHubClient.RejectAsync(message); } } } #else await Task.FromResult(default(object)); #endif }
public BusTestScenario(TimeSpan timeout, IBusControl busControl) { _timeout = timeout; _busControl = busControl; Received = new ReceivedMessageList(timeout); _skipped = new ReceivedMessageList(timeout); _published = new PublishedMessageList(timeout); _tokenSource = new CancellationTokenSource(timeout); CancellationToken = _tokenSource.Token; var testSendObserver = new TestSendObserver(timeout); Sent = testSendObserver.Messages; _subjectSendEndpoint = GetSendEndpoint(testSendObserver); var consumeObserver = new TestConsumeObserver(timeout); Received = consumeObserver.Messages; busControl.ConnectConsumeObserver(consumeObserver); _busHandle = _busControl.Start(); }
public SagaTestSubject(ISagaRepository <TSaga> sagaRepository) { _sagaRepository = sagaRepository; _received = new ReceivedMessageList(); _created = new SagaList <TSaga>(); _sagas = new SagaList <TSaga>(); }
public EndpointTestDecorator(IEndpoint endpoint, EndpointTestScenario scenario) { _endpoint = endpoint; _scenario = scenario; _sent = new SentMessageList(); _received = new ReceivedMessageList(); }
public SagaRepositoryTestDecorator(ISagaRepository <TSaga> sagaRepository, ReceivedMessageList received, SagaListImpl <TSaga> created, SagaListImpl <TSaga> sagas) { _sagaRepository = sagaRepository; _received = received; _created = created; _sagas = sagas; }
private void _mqttClient_CommandReceived(object sender, MqttMsgPublishEventArgs e) { var msg = new Models.ReceivedMessage(e.Message); msg.Topic = e.Topic; msg.MessageId = e.MessageId; DispatcherServices.Invoke(() => ReceivedMessageList.Insert(0, msg)); }
public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder) { _received = new ReceivedMessageList <TSubject>(builder.Timeout); var scenarioBuilder = builder as IBusTestScenarioBuilder; scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Handler <TSubject>(HandleMessage)); return(builder); }
public void Should_show_that_the_message_was_received_by_the_consumer() { var multiConsumer = new MultiConsumer(); ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>(); multiConsumer.Subscribe(LocalBus); LocalBus.Publish(new PingMessage()); received.Any().ShouldBeTrue(); }
public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder) { _received = new ReceivedMessageList(builder.Timeout); var decoratedConsumerFactory = new TestConsumerFactoryDecorator <TSubject>(_consumerFactory, _received); var scenarioBuilder = builder as IBusTestScenarioBuilder; scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Consumer(decoratedConsumerFactory)); return(builder); }
public void Should_show_that_the_message_was_received_by_the_consumer() { var multiConsumer = new MultiTestConsumer(TestTimeout); ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>(); using (ConnectHandle handle = multiConsumer.Connect(Bus)) { Bus.Publish(new PingMessage()); received.Select().Any().ShouldBe(true); } }
public ITestScenarioBuilder <TScenario> Configure(ITestScenarioBuilder <TScenario> builder) { _received = new ReceivedMessageList(builder.Timeout); _created = new SagaListImpl <TSaga>(builder.Timeout); _sagas = new SagaListImpl <TSaga>(builder.Timeout); var decoratedSagaRepository = new SagaRepositoryTestDecorator <TSaga>(_sagaRepository, _received, _created, _sagas); var scenarioBuilder = builder as IBusTestScenarioBuilder; scenarioBuilder?.ConfigureReceiveEndpoint(x => x.Saga(decoratedSagaRepository)); return(builder); }
public async Task Should_deliver_the_publish() { var multiConsumer = new MultiTestConsumer(TimeSpan.FromSeconds(8)); ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>(); var mediator = MassTransit.Bus.Factory.CreateMediator(cfg => { multiConsumer.Configure(cfg); }); await mediator.Publish(new PingMessage()); Assert.That(received.Select().Any(), Is.True); }
public async Task Should_show_that_the_message_was_received_by_the_consumer() { var multiConsumer = new MultiTestConsumer(TestTimeout); ReceivedMessageList <PingMessage> received = multiConsumer.Consume <PingMessage>(); var handle = Bus.ConnectReceiveEndpoint("boring2", x => multiConsumer.Configure(x)); await handle.Ready; try { await Bus.Publish(new PingMessage()); Assert.IsTrue(received.Select().Any()); } finally { await handle.StopAsync(); } }
public IConsumerTest <TScenario, TConsumer> Build() { // TODO pull from scenario _received = new ReceivedMessageList(TimeSpan.FromSeconds(8)); AddScenarioConfigurator(new ConsumerScenarioSpecification(_consumerFactory, _received)); TScenario scenario = BuildTestScenario(); IConsumerTestBuilder <TScenario, TConsumer> builder = _testBuilderFactory(scenario); builder.SetConsumerFactory(_consumerFactory); builder = _testSpecifications.Aggregate(builder, (current, configurator) => configurator.Configure(current)); BuildTestActions(builder); return(builder.Build()); }
public SensorNetwork(string str1, string str2, string str3) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.numNodes=int.Parse(str1); this.xmissionRange=float.Parse(str2); this.simulationSpeed=int.Parse(str3); rnd = new Random(); myPen = new Pen(Color.Blue); myLine=new Pen(Color.Gray); this.totMsgs=0; this.headNode=new SensorNode(true,this.xmissionRange,0, this.simulationSpeed); this.headRMsg=new ReceivedMessageList(); this.temp=this.headNode; this.tmpRMsg=this.headRMsg; this.headMsg=new MessageList();//dummy node got to be present at all times. this.tailMsg=new MessageList();//-do- this.headMsg.NEXT=this.tailMsg; this.numbers=new bool[this.numNodes]; this.timerFlag=false; this.stopperFlag2=false; for(int i=0;i<this.numNodes;i++) { this.tailNode=new SensorNode(false,this.xmissionRange,i+1,this.simulationSpeed); this.temp.Next=this.tailNode; this.temp=this.temp.Next; this.tailRMsg=new ReceivedMessageList(); this.tmpRMsg.Next=this.tailRMsg; this.tmpRMsg=this.tmpRMsg.Next; } }
protected EndpointTestScenario(IEndpointFactory endpointFactory) { _received = new ReceivedMessageList(); _sent = new SentMessageList(); _skipped = new ReceivedMessageList(); _published = new PublishedMessageList(); _endpoints = new Dictionary <Uri, EndpointTestDecorator>(); EndpointFactory = new EndpointFactoryTestDecorator(endpointFactory, this); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetConcurrentReceiverLimit(1); x.SetReceiveTimeout(50.Milliseconds()); x.EnableAutoStart(); }); }
public BusTestScenario(TimeSpan timeout, IBusControl busControl) { _timeout = timeout; _busControl = busControl; Received = new ReceivedMessageList(timeout); _skipped = new ReceivedMessageList(timeout); _published = new PublishedMessageList(timeout); _tokenSource = new CancellationTokenSource(timeout); CancellationToken = _tokenSource.Token; _subjectSendEndpoint = _busControl.GetSendEndpoint(new Uri("loopback://localhost/input_queue")).Result; var testSendObserver = new TestSendObserver(timeout); Sent = testSendObserver.Messages; _subjectSendEndpoint.ConnectSendObserver(testSendObserver); var consumeObserver = new TestConsumeObserver(timeout); Received = consumeObserver.Messages; busControl.ConnectConsumeObserver(consumeObserver); _busHandle = _busControl.Start(); }
public BusTestScenario(TimeSpan timeout, IBusControl busControl) { _timeout = timeout; _busControl = busControl; Received = new ReceivedMessageList(timeout); _skipped = new ReceivedMessageList(timeout); _published = new PublishedMessageList(timeout); _tokenSource = new CancellationTokenSource(timeout); CancellationToken = _tokenSource.Token; var testSendObserver = new TestSendObserver(timeout); Sent = testSendObserver.Messages; _subjectSendEndpoint = GetSendEndpoint(testSendObserver); var consumeObserver = new TestConsumeObserver(timeout); Received = consumeObserver.Messages; busControl.ConnectConsumeObserver(consumeObserver); _busHandle = _busControl.StartAsync(); }
public TestConsumeObserver(TimeSpan timeout) { _messages = new ReceivedMessageList(timeout); }
public TestDecoratorPipe(ReceivedMessageList received, IPipe <ConsumerConsumeContext <TConsumer, TMessage> > next) { _received = received; _next = next; }
public TestConsumerFactoryDecorator(IConsumerFactory <TConsumer> consumerFactory, ReceivedMessageList received) { _consumerFactory = consumerFactory; _received = received; }
public InterceptPipe(SagaListImpl <TSaga> sagas, ReceivedMessageList received, IPipe <SagaConsumeContext <TSaga, TMessage> > pipe) { _sagas = sagas; _received = received; _pipe = pipe; }
public ConsumerTestSubject(IConsumerFactory <TSubject> consumerFactory) { _consumerFactory = consumerFactory; _received = new ReceivedMessageList(); }
public PingConsumer(TimeSpan timeout, CancellationToken testCompleted) : base(timeout, testCompleted) { _messages = Fault <PingMessage>(); _faults = Consume <Fault <PingMessage> >(); }
public BaseMessageConsumer(TimeSpan timeout, CancellationToken testCompleted) : base(timeout, testCompleted) { _faults = Consume <Fault <BaseMessageType> >(); }
public BusTestConsumeObserver(TimeSpan timeout, CancellationToken testCompleted) { _messages = new ReceivedMessageList(timeout, testCompleted); }
public TestConsumeObserver(TimeSpan timeout, CancellationToken inactivityToken) { _messages = new ReceivedMessageList(timeout, inactivityToken); }
public HandlerTestSubject(Action <IConsumeContext <TSubject>, TSubject> handler) { _handler = handler; _received = new ReceivedMessageList <TSubject>(); }
public ConsumerScenarioSpecification(IConsumerFactory <TConsumer> consumerFactory, ReceivedMessageList received) { var decoratedConsumerFactory = new TestConsumerFactoryDecorator <TConsumer>(consumerFactory, received); _consumerFactory = decoratedConsumerFactory; }
public PingConsumer(TimeSpan timeout) : base(timeout) { _messages = Fault <PingMessage>(); _faults = Consume <Fault <PingMessage> >(); }