static void Main() { _structureMapContainer = new Container(); _structureMapContainer.Configure(p => p.Scan(x => x.TheCallingAssembly())); var messageTopics = new Dictionary <Type, string>(); messageTopics.Add(typeof(HelloMessage), "HelloMessage"); var handlerChannels = new Dictionary <Type, string>(); handlerChannels.Add(typeof(HelloMessageHandler), "LogProcessCrash-Channel"); // start the bus BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(_structureMapContainer), // dependency injection container new NewtonsoftJsonSerializer(typeof(JsonConvert).Assembly), // message serializer new MessageAuditor(), // receives received, started, and failed notifications new MessageTypeToTopicProvider( // mapping between .NET message types and topics messageTopics ), new HandlerTypeToChannelProvider( // mapping between IHandleMessages<T> implementations and channels handlerChannels ), busStateChangedHandler: new BusStateChangedHandler(), // bus starting/started/stopping/stopped preCreateTopicsAndChannels: true, // pre-create topics so we dont have to wait for an nsqlookupd cycle defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, // nsqlookupd address defaultThreadsPerHandler: 1, // threads per handler. tweak based on use case, see handlers in this project. logOnProcessCrash: true )); }
public void BusService_ConstructorEmpty_OK() { BusService bus = new BusService(); Assert.IsTrue(string.IsNullOrEmpty(bus.HostName)); Assert.IsTrue(string.IsNullOrEmpty(bus.KeyQueue)); }
public static void Start( IHandlerTypeToChannelProvider channelProvider, IBusStateChangedHandler busStateChangedHandler = null, IMessageTypeToTopicProvider topicProvider = null ) { if (channelProvider == null) { throw new ArgumentNullException("channelProvider"); } var config = new BusConfiguration( new StructureMapObjectBuilder(ObjectFactory.Container), new NewtonsoftJsonSerializer(typeof(JsonConvert).Assembly), new MessageAuditor(), topicProvider ?? new TopicProvider(), channelProvider, defaultThreadsPerHandler: 8, defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, busStateChangedHandler: busStateChangedHandler, preCreateTopicsAndChannels: true, nsqConfig: new NsqSharp.Config { BackoffStrategy = new FullJitterStrategy(), //MaxRequeueDelay = TimeSpan.FromSeconds(0.1), //MaxBackoffDuration = TimeSpan.FromSeconds(0.2) } ); BusService.Start(config); }
public ActionResult AddBusService(BusService busService, HttpPostedFileBase UpdateImage, HttpPostedFileBase Image) { if (busService.Id > 0) { if (UpdateImage != null) { string filename = UpdateImage.FileName; busService.Image = filename; string path = Path.Combine(Server.MapPath("/Images"), filename); UpdateImage.SaveAs(path); } _context.Entry(busService).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("BusService")); } else { string filename = Image.FileName; busService.Image = filename; string path = Path.Combine(Server.MapPath("/Images"), filename); Image.SaveAs(path); _context.BusServices.Add(busService); _context.SaveChanges(); return(RedirectToAction("BusService")); } }
public void BusService_ConstructorFilled_OK() { BusService bus = new BusService("hostname", "key"); Assert.IsFalse(string.IsNullOrEmpty(bus.HostName)); Assert.IsFalse(string.IsNullOrEmpty(bus.KeyQueue)); }
static void Main() { var container = SetupDependencyInjectionContainer(); // start the bus BusService.Start(new BusConfiguration( new ObjectBuilder(container), // dependency injection container new MessageSerializer(), // message serializer new MessageAuditor(), // receives received, started, and failed notifications new MessageTypeToTopicProvider(), // mapping between .NET message types and topics new HandlerTypeToChannelProvider(), // mapping between IHandleMessages<T> implementations and channels busStateChangedHandler: new BusStateChangedHandler(), // bus starting/started/stopping/stopped defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, // nsqlookupd address defaultThreadsPerHandler: 1, // threads per handler. tweak based on use case, see handlers in this project. nsqConfig: new Config { // optional override of default config values MaxRequeueDelay = TimeSpan.FromSeconds(15), MaxBackoffDuration = TimeSpan.FromSeconds(2), MaxAttempts = 2 }, nsqLogger: new TraceLogger(), // logger for NSQ events (see also ConsoleLogger, or implement your own) preCreateTopicsAndChannels: true // pre-create topics so we dont have to wait for an nsqlookupd cycle )); // BusService.Start blocks until Ctrl+C pressed when in Console mode var counter = container.GetInstance <ICounter>(); Console.WriteLine("{0:#,0} msgs/sec", counter.Current / counter.Elapsed.TotalSeconds); }
static void Main() { // new dependency injection container var container = new Container(); // start the bus BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(container), // dependency injection container new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), // message serializer new ConsoleMessageAuditor(), // receives received, started, and failed notifications new MessageTypeToTopicDictionary( // mapping between .NET message types and topics new Dictionary <Type, string> { { typeof(EchoMessage), "echo-topic" }, { typeof(ReverseEchoMessage), "reverse-echo-topic" } } ), new HandlerTypeToChannelDictionary( // mapping between IHandleMessages<T> implementations and channels new Dictionary <Type, string> { { typeof(EchoMessageHandler), "echo-channel" }, { typeof(ReverseEchoMessageHandler), "reverse-echo-channel" } } ), busStateChangedHandler: new BusStateChangedHandler(), defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, nsqLogger: new ConsoleLogger(LogLevel.Info), // default = TraceLogger defaultThreadsPerHandler: 1, // threads per handler. tweak based on use case. preCreateTopicsAndChannels: true // pre-create topics so we dont have to wait for an nsqlookupd cycle )); }
public QrCodeController(QrCodeService qrCodeservice, BusService busService, UserService userService, RidesService ridesService) { this.qrCodeService = qrCodeservice; this.busService = busService; this.userService = userService; this.ridesService = ridesService; }
public void Post([FromBody] FridgeClass value) { string json = JsonSerializer.Serialize(value); BusService service = new BusService(_connectionString); service.Send(json); }
public void Given_A_Handler_Implementing_Multiple_IHandleMessages_When_Bus_Starts_Then_An_Exception_Should_Be_Thrown() { string highPriorityTopicName = string.Format("test_high_priority_{0}", DateTime.Now.UnixNano()); string lowPriorityTopicName = string.Format("test_low_priority_{0}", DateTime.Now.UnixNano()); const string channelName = "test_channel"; var container = new Container(); // UpdateHandler implements IHandleMessages multiple times Assert.Throws <HandlerConfigurationException>(() => BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(container), new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), new MessageAuditorStub(), new MessageTypeToTopicDictionary(new Dictionary <Type, string> { { typeof(HighPriority <UpdateMessage>), highPriorityTopicName }, { typeof(LowPriority <UpdateMessage>), lowPriorityTopicName } }), new HandlerTypeToChannelDictionary(new Dictionary <Type, string> { { typeof(UpdateHandler), channelName }, }), defaultNsqLookupdHttpEndpoints: new[] { "0.0.0.0:0" }, defaultThreadsPerHandler: 4, nsqConfig: new Config { LookupdPollJitter = 0, LookupdPollInterval = TimeSpan.FromSeconds(1), } ))); // the safe way (explicit channel names for each IHandleMessages<>) container.Configure(x => { x.For <IHandleMessages <HighPriority <UpdateMessage> > >().Use <UpdateHandler>(); x.For <IHandleMessages <LowPriority <UpdateMessage> > >().Use <UpdateHandler>(); }); BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(container), new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), new MessageAuditorStub(), new MessageTypeToTopicDictionary(new Dictionary <Type, string> { { typeof(HighPriority <UpdateMessage>), highPriorityTopicName }, { typeof(LowPriority <UpdateMessage>), lowPriorityTopicName } }), new HandlerTypeToChannelDictionary(new Dictionary <Type, string> { { typeof(IHandleMessages <HighPriority <UpdateMessage> >), channelName }, { typeof(IHandleMessages <LowPriority <UpdateMessage> >), channelName } }), defaultNsqLookupdHttpEndpoints: new[] { "0.0.0.0:0" }, defaultThreadsPerHandler: 4, nsqConfig: new Config { LookupdPollJitter = 0, LookupdPollInterval = TimeSpan.FromSeconds(1), } )); }
public static IServiceCollection AddRabbitMQServices(this IServiceCollection services, QueueConfigModel queueConfigModel) { services.AddMassTransit(cfg => { cfg.AddBus(provider => BusService.ConfigureBusService(provider, queueConfigModel)); }); return(services); }
public MainForm() { InitializeComponent(); _busService = new BusService(); PopulateListView(); edit_button.Enabled = false; delete_button.Enabled = false; _deletedBuses = new List <Bus>(); }
protected void btnGetAccounts_DirectClick(object sender, Ext.Net.DirectEventArgs e) { Bus bus = new Bus(); BusService service = new BusService(); Store str = grdBus.GetStore(); str.DataSource = Database.Session.QueryOver <Bus>().Where(x => x.state == true).List(); str.DataBind(); }
public DeleteBusActor(BusService busService) { _busService = busService; Receive <string>(busId => { _busService.Remove(busId); Sender.Tell(true); }); }
public AddBusForm(MainForm mainForm) { InitializeComponent(); _busService = new BusService(); _mainForm = mainForm; departing_dateTimePicker.Format = DateTimePickerFormat.Custom; departing_dateTimePicker.CustomFormat = @"dd.MM.yyy HH:mm"; arrival_dateTimePicker.Format = DateTimePickerFormat.Custom; arrival_dateTimePicker.CustomFormat = @"dd.MM.yyyy HH:mm"; }
private void BuildResponseActions() { connection.On <HamBusError>(SignalRCommands.ErrorReport, (errorReport) => HBErrors__ !.OnNext(errorReport)); connection.On <UiInfoPacketModel>(SignalRCommands.InfoPacket, (info) => { Log.Verbose("In on infoPacket"); BusService.UpdateFromInfoPacket(info); Log.Debug("{@info} of log of info", info); InfoPacket__ !.OnNext(info); });
public ActionResult BusService(BusService busService, HttpPostedFileBase Image) { if (Session["Id"] != null) { return(View(_context.BusServices.ToList())); } else { return(RedirectToAction("LogIn")); } }
public UpdateBusActor(string busId, BusService busService) { _busId = busId; _busService = busService; Receive <Bus>(bus => { _busService.Update(_busId, bus); Sender.Tell(true); }); }
private static async Task <BusService> GetServiceFromKml(string filePath) { using (var reader = File.OpenText(filePath)) { var kml = KmlFile.Load(reader); var nodes = kml.Root.Flatten(); var document = nodes.OfType <Document>().Single(); var routes = new List <Route>(); var landmarks = new List <PlaceDetail>(); var placemarks = nodes.OfType <Placemark>(); foreach (var placemark in placemarks) { var geometries = placemark.Geometry.Flatten().ToLookup(geometry => geometry.GetType()); foreach (LineString line in geometries[typeof(LineString)]) { var coordinates = line.Coordinates.Select(pair => new Coordinate(pair.Latitude, pair.Longitude)); var snapped = await GMapsClient.SnapToRoadsAsync(coordinates); var placeIds = snapped.Select(snappedPlace => snappedPlace.PlaceId).Distinct(); var places = await Task.WhenAll( placeIds.Select(id => GMapsClient.GetPlaceDetailAsync(id)) ); var route = new Route { Name = placemark.Name, Places = places, }; routes.Append(route); } foreach (Point point in geometries[typeof(Point)]) { // TODO get place id from coordinate? // Could just use embedded info. } } var service = new BusService { Name = document.Name, Routes = routes, Landmarks = landmarks, }; return(service); } }
public EditBusForm(MainForm mainForm, Bus bus) { InitializeComponent(); _busService = new BusService(); _mainForm = mainForm; _bus = bus; departing_dateTimePicker.Format = DateTimePickerFormat.Custom; departing_dateTimePicker.CustomFormat = @"dd.MM.yyy HH:mm"; arrival_dateTimePicker.Format = DateTimePickerFormat.Custom; arrival_dateTimePicker.CustomFormat = @"dd.MM.yyyy HH:mm"; FillBusData(); }
protected void btnKaydet_DirectClick(object sender, DirectEventArgs e) { if (txtPlate.Text == "") { X.Msg.Alert("UYARI", "Boş Alan Bırakmayınız.").Show(); return; } if (txtModel.Text == "") { X.Msg.Alert("UYARI", "Boş Alan Bırakmayınız.").Show(); return; } if (Convert.ToInt32(txtMaxPassenger.Value) <= 0) { X.Msg.Alert("UYARI", "Boş Alan Bırakmayınız.").Show(); return; } BusService service = new BusService(); if (TextbusId.Text == "") { Bus bus = new Bus() { plate = txtPlate.Text, busModel = txtModel.Text, maxBusPessenger = Convert.ToInt32(txtMaxPassenger.Value) }; service.saveOrUpdate(bus); } else { Bus bus = new Bus() { busId = Convert.ToInt32(TextbusId.Text), plate = txtPlate.Text, busModel = txtModel.Text, maxBusPessenger = Convert.ToInt32(txtMaxPassenger.Value) }; service.saveOrUpdate(bus); } txtMaxPassenger.Clear(); txtModel.Clear(); txtPlate.Clear(); X.Msg.Alert("UYARI", "Bilgiler kayıt edilmiştir.").Show(); Window1.Hide(this.Form); btnGetAccounts_DirectClick(new object(), new DirectEventArgs(null)); }
protected void btnDeleteConfirmSave_DirectClick(object sender, DirectEventArgs e) { Store str = grdBus.GetStore(); Bus bus = new Bus(); BusService busService = new BusService(); //service.delete(bus); bus.plate = hdnBusDelete.Value.ToString(); bus = busService.delete(bus); btnGetAccounts_DirectClick(new object(), new DirectEventArgs(null)); wndDeleteConfirm.Hide(); }
static void Main() { // Run nsqd using TLS: // // nsqd -tls-cert="cert.pem" -tls-key="privatekey.pem" -tls-required=1 -https-address=0.0.0.0:4152 -lookupd-tcp-address=127.0.0.1:4160 // // See https://github.com/judwhite/NsqSharp/wiki/Securing-NSQ-with-TLS-and-Auth for more info // // Self-signed test keys are in the ./test-keys folder in this project. // In order to use self-signed keys TlsConfig.InsecureSkipVerify must be set to true. // new dependency injection container var container = new ContainerBuilder().Build(); var nsqConfig = new Config { TlsConfig = new TlsConfig { MinVersion = SslProtocols.Tls12, InsecureSkipVerify = true // NOTE: For testing only }, LookupdPollInterval = TimeSpan.FromSeconds(5), DialTimeout = TimeSpan.FromSeconds(10) }; // start the bus BusService.Start(new BusConfiguration( new AutofacObjectBuilder(container), // dependency injection container new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), // message serializer new ConsoleMessageAuditor(), // receives received, started, and failed notifications new MessageTypeToTopicDictionary( // mapping between .NET message types and topics new Dictionary <Type, string> { { typeof(EchoMessage), "echo-topic-tls" }, { typeof(ReverseEchoMessage), "reverse-echo-topic-tls" } } ), new HandlerTypeToChannelDictionary( // mapping between IHandleMessages<T> implementations and channels new Dictionary <Type, string> { { typeof(EchoMessageHandler), "echo-channel-tls" }, { typeof(ReverseEchoMessageHandler), "reverse-echo-channel-tls" } } ), busStateChangedHandler: new BusStateChangedHandler(), defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, nsqLogger: new ConsoleLogger(LogLevel.Info), // default = TraceLogger defaultThreadsPerHandler: 1, // threads per handler. tweak based on use case. nsqConfig: nsqConfig )); }
public EditRouteDialog(int routeId, BusService busService, ObservableCollection <BusStation> busStations, List <RouteStationViewModel> routeDetailsForRoute, int routeVariant) { _routeId = routeId; _routeVariant = routeVariant; InitializeComponent(); BusService = busService; BusStations = busStations; StationsList.ItemsSource = BusStations; Route = new ObservableCollection <RouteStationViewModel>(); foreach (var rd in routeDetailsForRoute) { Route.Add(rd); } DataContext = this; }
public GetBusActor(BusService busService) { _busService = busService; Receive <string>(message => { if (string.Equals(message, findAllCommand, System.StringComparison.OrdinalIgnoreCase)) { Sender.Tell(_busService.Get()); } else { Sender.Tell(_busService.Get(message)); } }); }
public static IServiceCollection AddRabbitMQConsumerServices <T>(this IServiceCollection services, QueueConfigModel queueConfigModel) where T : class, IConsumer { services.AddMassTransit(cfg => { cfg.AddConsumer <T>(); cfg.AddBus(provider => BusService.ConfigureBusService(provider, queueConfigModel, (cfg, host) => { cfg.ReceiveEndpoint(queueConfigModel.QueueName, ep => { ep.ConfigureConsumer <T>(provider); }); })); }); services.AddMassTransitHostedService(); return(services); }
public CreateBusActor(BusService busService) { _busService = busService; Receive <Bus>(bus => { _originalSender = Sender; _bus = bus; if (_bus.BusLineId == null) { Props AssignLineActorProps = Props.Create(() => new AssignLineActor()); var assignLineActor = Context.ActorOf(AssignLineActorProps); assignLineActor.Tell(AssignLineActor.startCommand); } else { Bus createdBus = _busService.Create(_bus); _originalSender.Tell(createdBus); } }); Receive <string>(message => { Bus createdBus; /* create the bus with no line assigned if no line could be retrieved * could then update it later or add logging around this without * stopping a bus from being created in the system */ if (string.IsNullOrEmpty(message)) { createdBus = _busService.Create(_bus); } else { _bus.BusLineId = message; createdBus = _busService.Create(_bus); } _originalSender.Tell(createdBus); }); }
public void Given_A_Thread_Not_Handling_A_Message_When_GetCurrentMessageInformation_Called_The_Result_Should_Be_Null() { string topicName = string.Format("test_getcurrentmessageinformation_{0}", DateTime.Now.UnixNano()); const string channelName = "test_getcurrentmessageinformation"; var container = new Container(); _nsqdHttpClient.CreateTopic(topicName); _nsqLookupdHttpClient.CreateTopic(topicName); try { BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(container), new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), new MessageAuditorStub(), new MessageTypeToTopicDictionary(new Dictionary <Type, string> { { typeof(TestMessage), topicName } }), new HandlerTypeToChannelDictionary(new Dictionary <Type, string> { { typeof(TestMessageHandler), channelName } }), defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, defaultThreadsPerHandler: 1, nsqConfig: new Config { LookupdPollJitter = 0, LookupdPollInterval = TimeSpan.FromSeconds(1) } )); var bus = container.GetInstance <IBus>(); Assert.IsNull(bus.GetCurrentThreadMessageInformation(), "bus.GetCurrentThreadMessageInformation()"); } finally { BusService.Stop(); _nsqdHttpClient.DeleteTopic(topicName); _nsqLookupdHttpClient.DeleteTopic(topicName); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dtcallback = new DataTable(); DataSet DsSub = new DataSet(); DataSet dsrefcalback = new DataSet(); DataSet ds = new DataSet(); DataTable dtds = new DataTable(); DsSub.ReadXml(Server.MapPath("~/App_Data/XMLfiles/" + "Callback.xml")); dsrefcalback.ReadXml(Server.MapPath("~/App_Data/XMLfiles/" + "RefCallback.xml")); IEnumerable<DataRow> SubData = from i in DsSub.Tables[0].AsEnumerable() where i.Field<string>("status") == Convert.ToString(0) && i.Field<string>("readMode") == Convert.ToString(0) select i; if (SubData.Count() > 0) { foreach (DataRow dr in SubData) { string resrId = Convert.ToString(dr["sync_reservation_ids"]); if (reservation_Id.ToString() == "") { reservation_Id = resrId; } else { reservation_Id = reservation_Id + "," + resrId; } } //var lengthCount = reservation_Id.Distinct().ToList(); string[] str = reservation_Id.Split(','); string[] res_id = str.Distinct().ToArray(); // var splitted = reservation_Id.AsEnumerable().SelectMany(item => item.ToString()).Distinct(); //foreach (DataRow dr in SubData) //{ if (res_id.Count() > 0) { BusService bus = new BusService(); DateTime strdt = System.DateTime.Now; string us = strdt.ToString(new CultureInfo("en-US")); string[] date = us.Split(' '); //string resrId = Convert.ToString(dr["sync_reservation_ids"]); //if (resrId.Contains(',')) //{ // IDS = resrId.Split(','); //} //else //{ // IDS = resrId.Split(' '); //} foreach (var id in res_id) { DataSet ds1 = bus.getServiceDetails(Convert.ToString(id), date[0]); //to find in which date file we need to update IEnumerable<DataRow> SubDataDate = from j in dsrefcalback.Tables[0].AsEnumerable() where j.Field<string>("reservation_id") == Convert.ToString(id) select j; foreach (DataRow datenew in SubDataDate) { if (File.Exists(HttpContext.Current.Server.MapPath("~\\Routes\\" + datenew["Date"] + ".xml"))) { ds.ReadXml(Server.MapPath("~/Routes/" + datenew["Date"] + ".xml")); ViewState["Date"] = datenew["Date"]; } else { ds = null; } } if (ds1 != null) { foreach (DataRow dtrow in ds1.Tables[0].Rows) { if (ds != null) { IEnumerable<DataRow> SubData1 = from j in ds.Tables[0].AsEnumerable() where j.Field<string>("reservation_id") == Convert.ToString(id) select j; foreach (DataRow dr1 in SubData1) { XmlTextReader reader = new XmlTextReader(Server.MapPath("~/Routes/" + Convert.ToString(ViewState["Date"]) + ".xml")); XmlDocument doc = new XmlDocument(); doc.Load(reader); reader.Close(); XmlNode oldCd; XmlElement root = doc.DocumentElement; oldCd = root.SelectSingleNode("/routes/route[reservation_id='" + id + "']"); foreach(XmlNode node in oldCd) { if (node.Name == "id") { strid = node.InnerXml; } if (node.Name == "number") { number = node.InnerXml; } if (node.Name == "name") { name = node.InnerXml; } if (node.Name == "operator_service_name") { operator_service_name = node.InnerXml; } if (node.Name == "origin") { origin = node.InnerXml; } if (node.Name == "destination") { destination = node.InnerXml; } if (node.Name == "origin_id") { origin_id = node.InnerXml; } if (node.Name == "destination_id") { destination_id = node.InnerXml; } if (node.Name == "reservation_id") { reservation_id = node.InnerXml; } if (node.Name == "operator_route_id") { operator_route_id = node.InnerXml; } if (node.Name == "travel_id") { travel_id = node.InnerXml; } if (node.Name == "travels") { travels = node.InnerXml; } if (node.Name == "bus_type") { bus_type = node.InnerXml; } if (node.Name == "bus_type_id") { bus_type_id = node.InnerXml; } if (node.Name == "dep_time") { dep_time = node.InnerXml; } if (node.Name == "arr_time") { arr_time = node.InnerXml; } if (node.Name == "duration") { duration = node.InnerXml; } if (node.Name == "available_seats") { available_seats = node.InnerXml; } if (node.Name == "total_seats") { total_seats = node.InnerXml; } if (node.Name == "seat_type_detail") { seat_type_detail = node.InnerXml; } if (node.Name == "fare_str") { fare_str = node.InnerXml; } if (node.Name == "is_cancellable") { is_cancellable = node.InnerXml; } if (node.Name == "commission") { commission = node.InnerXml; } if (node.Name == "status") { status = node.InnerXml; } } XmlElement newCd = doc.CreateElement("route"); newCd.InnerXml = "<id>" + strid + "</id>" + "<number>" + number + "</number>" + "<name>" + name + "</name>" + "<operator_service_name>" + operator_service_name + "</operator_service_name>" + "<origin>" + origin + "</origin>" + "<destination>" + destination + "</destination>" + "<origin_id>" + origin_id + "</origin_id>" + "<destination_id>" + destination_id + "</destination_id>" + "<reservation_id>" + reservation_id + "</reservation_id>" + "<operator_route_id>" + operator_route_id + "</operator_route_id>" + "<travel_id>" + travel_id + "</travel_id>" + "<travels>" + travels + "</travels>" + "<bus_type>" + bus_type + "</bus_type>" + "<bus_type_id>" + bus_type_id + "</bus_type_id>" + "<dep_time>" + ds1.Tables["boardingTimes"].Rows[0]["time"].ToString() + "</dep_time>" + "<arr_time>" + ds1.Tables["droppingTimes"].Rows[0]["time"].ToString() + "</arr_time>" + "<duration>" + duration+ "</duration>" + "<available_seats>" + Convert.ToString(dtrow["availableSeatsCount"]) + "</available_seats>" + "<total_seats>" + total_seats + "</total_seats>" + "<seat_type_detail>" + seat_type_detail + "</seat_type_detail>" + "<fare_str>" + fare_str + "</fare_str>" + "<is_cancellable>" + is_cancellable + "</is_cancellable>" + "<commission>" + commission + "</commission>" + "<status>" + status + "</status>"; root.ReplaceChild(newCd, oldCd); doc.Save(Server.MapPath("~/Routes/" + Convert.ToString(ViewState["Date"]) + ".xml")); //if (Convert.ToString(dtrow["availableSeats"]) != "") //{ // dr1["available_seats"] = Convert.ToString(dtrow["availableSeats"]); //} //if (ds1.Tables["boardingTimes"].Columns.Contains("time")) //{ // dr1["dep_time"] = ds1.Tables["boardingTimes"].Rows[0]["time"].ToString(); //} //if (Convert.ToString(dtrow["availableSeatsCount"]) != "") //{ // dr1["available_seats"] = Convert.ToString(dtrow["availableSeatsCount"]); //} //if (ds1.Tables["droppingTimes"].Columns.Contains("time")) //{ // dr1["arr_time"] = ds1.Tables["droppingTimes"].Rows[0]["time"].ToString(); //} } } } } //if (ds != null) //{ // StreamWriter XmlData = new StreamWriter(Server.MapPath("~/Routes/" + Convert.ToString(ViewState["Date"]) + ".xml"), false); // ds.WriteXml(XmlData); // XmlData.Close(); //} } //dr["status"] = "1"; //StreamWriter XmlDatacallback = new StreamWriter(Server.MapPath("~/App_Data/XMLfiles/" + "Callback.xml"), false); //DsSub.WriteXml(XmlDatacallback); //XmlDatacallback.Close(); } } } }
public GeoController(BusService busService) { _busService = busService; }
public void Given_Two_Queues_In_One_Process_When_One_Queue_Is_Long_Then_It_Should_Not_Block_Other_Queues() { string highPriorityTopicName = string.Format("test_high_priority_{0}", DateTime.Now.UnixNano()); const string highPriorityChannelName = "test_high_priority"; string lowPriorityTopicName = string.Format("test_low_priority_{0}", DateTime.Now.UnixNano()); const string lowPriorityChannelName = "test_low_priority"; var container = new Container(); container.Configure(x => { x.For <IHandleMessages <HighPriority <UpdateMessage> > >().Use <UpdateHandler>(); x.For <IHandleMessages <LowPriority <UpdateMessage> > >().Use <UpdateHandler>(); }); try { BusService.Start(new BusConfiguration( new StructureMapObjectBuilder(container), new NewtonsoftJsonSerializer(typeof(JsonConverter).Assembly), new MessageAuditorStub(), new MessageTypeToTopicDictionary(new Dictionary <Type, string> { { typeof(HighPriority <UpdateMessage>), highPriorityTopicName }, { typeof(LowPriority <UpdateMessage>), lowPriorityTopicName } }), new HandlerTypeToChannelDictionary(new Dictionary <Type, string> { { typeof(IHandleMessages <HighPriority <UpdateMessage> >), highPriorityChannelName }, { typeof(IHandleMessages <LowPriority <UpdateMessage> >), lowPriorityChannelName } }), defaultNsqLookupdHttpEndpoints: new[] { "127.0.0.1:4161" }, defaultThreadsPerHandler: 4, nsqConfig: new Config { LookupdPollJitter = 0, LookupdPollInterval = TimeSpan.FromSeconds(1), } )); var bus = container.GetInstance <IBus>(); var lowPriorityMessage = UpdateMessage.LowPriority(p => p.Id = "low"); var highPriorityMessage = UpdateMessage.HighPriority(p => p.Id = "high"); bus.Send(highPriorityMessage); bus.Send(lowPriorityMessage); Thread.Sleep(TimeSpan.FromSeconds(6)); UpdateHandler.Reset(); // publishing registers this nsqd as a producer, causes consumer to connect via lookup service // TODO: this test would be faster if the cosumer connected to nsqd directly, but that's not the // TODO: pattern to encourage // send 1000 low priority message var lowPriorityMessages = new List <LowPriority <UpdateMessage> >(); for (int i = 0; i < 1000; i++) { lowPriorityMessages.Add(lowPriorityMessage); } bus.SendMulti(lowPriorityMessages); // let some go through Thread.Sleep(40); int lowCountAtSendHigh = UpdateHandler.GetCount(); // send 1 high priority message bus.Send(highPriorityMessage); // wait for nsqlookupd cycle / consumer + processing time var list = UpdateHandler.GetList(); int highIndex = -1; for (int i = 0; i < list.Count; i++) { if (list[i].Id == "high") { highIndex = i; break; } } Console.WriteLine("lowCountAtSendHigh: {0}", lowCountAtSendHigh); Console.WriteLine("highIndex: {0}", highIndex); Console.WriteLine("total: {0}", list.Count); Assert.Less(lowCountAtSendHigh, 800, "lowCountAtSendHigh"); Assert.Greater(lowCountAtSendHigh, 100, "lowCountAtSendHigh"); Assert.Less(highIndex, lowCountAtSendHigh + 50, "highIndex"); // checks stats from http server var stats = _nsqdHttpClient.GetStats(); // assert high priority stats var highTopic = stats.Topics.Single(p => p.TopicName == highPriorityTopicName); var highChannel = highTopic.Channels.Single(p => p.ChannelName == highPriorityChannelName); Assert.AreEqual(2, highTopic.MessageCount, "highTopic.MessageCount"); // kickoff + 1 message Assert.AreEqual(0, highTopic.Depth, "highTopic.Depth"); Assert.AreEqual(0, highTopic.BackendDepth, "highTopic.BackendDepth"); Assert.AreEqual(2, highChannel.MessageCount, "highChannel.MessageCount"); // kickoff + 1 message Assert.AreEqual(0, highChannel.DeferredCount, "highChannel.DeferredCount"); Assert.AreEqual(0, highChannel.Depth, "highChannel.Depth"); Assert.AreEqual(0, highChannel.BackendDepth, "highChannel.BackendDepth"); Assert.AreEqual(0, highChannel.InFlightCount, "highChannel.InFlightCount"); Assert.AreEqual(0, highChannel.TimeoutCount, "highChannel.TimeoutCount"); Assert.AreEqual(0, highChannel.RequeueCount, "highChannel.RequeueCount"); // assert low priority stats var lowTopic = stats.Topics.Single(p => p.TopicName == lowPriorityTopicName); var lowChannel = lowTopic.Channels.Single(p => p.ChannelName == lowPriorityChannelName); Assert.AreEqual(1001, lowTopic.MessageCount, "lowTopic.MessageCount"); // kickoff + 1000 messages Assert.AreEqual(0, lowTopic.Depth, "lowTopic.Depth"); Assert.AreEqual(0, lowTopic.BackendDepth, "lowTopic.BackendDepth"); Assert.AreEqual(1001, lowChannel.MessageCount, "lowChannel.MessageCount"); // kickoff + 1000 messages Assert.AreEqual(0, lowChannel.DeferredCount, "lowChannel.DeferredCount"); Assert.AreEqual(0, lowChannel.Depth, "lowChannel.Depth"); Assert.AreEqual(0, lowChannel.BackendDepth, "lowChannel.BackendDepth"); Assert.AreEqual(0, lowChannel.InFlightCount, "lowChannel.InFlightCount"); Assert.AreEqual(0, lowChannel.TimeoutCount, "lowChannel.TimeoutCount"); Assert.AreEqual(0, lowChannel.RequeueCount, "lowChannel.RequeueCount"); } finally { BusService.Stop(); _nsqdHttpClient.DeleteTopic(highPriorityTopicName); _nsqLookupdHttpClient.DeleteTopic(highPriorityTopicName); _nsqdHttpClient.DeleteTopic(lowPriorityTopicName); _nsqLookupdHttpClient.DeleteTopic(lowPriorityTopicName); } }