public static Uri GetUriFor(ITransportFactory fac) { var asbAccountDetails = new AccountDetails(); return new Dictionary<Type, Uri> { { typeof (TransportFactoryImpl), asbAccountDetails.WithApplication("TransportSpecs").BuildUri() }, { typeof(MsmqTransportFactory), new Uri(fac.Scheme + "://localhost/TransportSpecs") }, { typeof(RabbitMqTransportFactory), new Uri(fac.Scheme + "://localhost/TransportSpecs") }, { typeof(LoopbackTransportFactory), new Uri(fac.Scheme + "://localhost/TransportSpecs")} } [fac.GetType()]; }
private static Uri GetEndpointUrl(string applicationName) { var details = new AccountDetails(); return details.BuildUri(applicationName); }
public override void Run() { // This is a sample worker implementation. Replace with your logic. _logger.Info("starting receiver"); RoleEnvironment.Stopping += (sender, args) => _isStopping = true; ConfigureDiagnostics(); var stopping = new AutoResetEvent(false); long rampUp = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("RampUpCount")); long sampleSize = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("SampleSize")); long failures = 0; long received = 0; var watch = new Stopwatch(); var datapoints = new LinkedList<DataPoint>(); var senders = new LinkedList<IEndpoint>(); var maxSenders = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("WaitForNumberOfSenders")); var allSendersUp = new CountdownEvent(maxSenders); var creds = new AccountDetails(); using (var sb = ServiceBusFactory.New(sbc => { sbc.ReceiveFrom(creds.BuildUri("receiver")); sbc.SetPurgeOnStartup(true); sbc.UseNLog(); sbc.UseAzureServiceBus(); sbc.UseAzureServiceBusRouting(); })) { UnsubscribeAction unsubscribeMe = null; unsubscribeMe += sb.SubscribeHandler<SenderUp>(su => { _logger.Info("received SenderUp!"); lock (senders) { var endpoint = sb.GetEndpoint(su.Source); if (!senders.Any(x => x.Address.Uri.Equals(endpoint.Address.Uri)) && allSendersUp.CurrentCount < maxSenders) { senders.AddLast(endpoint); allSendersUp.Signal(); } } }); _logger.Info("waiting for all senders ..."); allSendersUp.Wait(); _logger.Info("sending 'ReadySetGo' to all senders"); lock (senders) senders.Each(sender => sender.Send<ReadySetGo>(new {})); //unsubscribeMe = sb.SubscribeHandler<IConsumeContext<ZoomZoom>>(consumeContext => unsubscribeMe += sb.SubscribeHandler<ZoomZoom>(payment => { //var payment = consumeContext.Message; long currentReceived; if ((currentReceived = Interlocked.Increment(ref received)) == rampUp) watch.Start(); else if (currentReceived < rampUp) return; var localFailures = new long?(); if (Math.Abs(payment.Amount - 1024m) > 0.0001m) { localFailures = Interlocked.Increment(ref failures); } if (currentReceived + rampUp == sampleSize || _isStopping) { unsubscribeMe(); watch.Stop(); stopping.Set(); } if (currentReceived % 100 == 0) { var point = new DataPoint { Received = currentReceived, Ticks = watch.ElapsedTicks, Failures = localFailures ?? failures, SampleMessage = payment, Instance = DateTime.UtcNow /* assume all prev 100 msgs same size */ //Size = consumeContext.BaseContext.BodyStream.Length * 100 }; lock (datapoints) datapoints.AddLast(point); _logger.Debug(string.Format("Logging {0}", point)); } }); PipelineViewer.Trace(sb.InboundPipeline); _logger.Info("waiting for all messages!"); stopping.WaitOne(); sb.GetEndpoint(creds.BuildUri("sender")).Send<ZoomDone>(new{}); } _logger.Info( string.Format(@" Performance Test Done ===================== Total messages received: {0} Time taken: {1} of which: Corrupt messages count: {2} Valid messages count: {3} metrics: Message per second: {4} Total bytes transferred:{5} All samples' data equal:{6} data points: {7} ", sampleSize, watch.Elapsed, failures, sampleSize-failures, 1000d * sampleSize / (double)watch.ElapsedMilliseconds, datapoints.Sum(dp => dp.Size), datapoints.Select(x => x.SampleMessage).All(x => x.Payload.Equals(TestData.PayloadMessage, StringComparison.InvariantCulture)), datapoints.Aggregate("", (str, dp) => str + dp.ToString() + Environment.NewLine))); _logger.Info("Idling... aka. softar."); while (true) Thread.Sleep(10000); // now have a look in Server Explorer, WADLogsTable, w/ Filter similar to "Timestamp gt datetime'2012-02-03T10:06:50Z'" // (if this isn't your first deployment, or no filter if you feel like that) }