Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            new AppHost().Init();

            //*** Start RestBus subscriber/host **//

            var amqpUrl     = "amqp://localhost:5672"; //AMQP URL for RabbitMQ installation
            var serviceName = "samba";                 //Uniquely identifies this service

            var msgMapper  = new BasicMessageMapper(amqpUrl, serviceName);
            var subscriber = new RestBusSubscriber(msgMapper);

            restbusHost = new RestBusHost(subscriber);
            restbusHost.Start();

            //****//
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string baseAddress = "http://localhost:8000/";
            //Initialize startup object
            var startup = new Startup();

            // Start OWIN host
            using (WebApp.Start(url: baseAddress, startup: startup.Configuration))
            {
                Console.WriteLine("Starting web Server...");
                Console.WriteLine("Server running at {0} - press Enter to quit. ", baseAddress);

                //Start RestBus Subscriber/host
                var amqpUrl     = "amqp://localhost:5672"; //AMQP URI for RabbitMQ server
                var serviceName = "trades";                //Uniquely identifies this service

                var msgMapper  = new BasicMessageMapper(amqpUrl, serviceName);
                var subscriber = new RestBusSubscriber(msgMapper);
                using (var host = new RestBusHost(subscriber, startup.Config))
                {
                    host.Start();
                    Console.ReadLine();
                }
            }
        }
Esempio n. 3
0
        static void Main()
        {
            //Initialize startup object
            var startup = new Startup();

            string baseAddress = null;

            //baseAddress = "http://localhost:9000/"; //Uncomment this line to also listen on localhost:9000

            //Start WebAPI OWIN host
            using (WebApp.Start(url: baseAddress, startup: startup.Configuration))
            {
                //Start RestBus Subscriber/host

                var amqpUrl     = ConfigurationManager.AppSettings["ServerUri"]; //AMQP URI for RabbitMQ server
                var serviceName = "speedtest";                                   //Uniquely identifies this service

                var msgMapper  = new BasicMessageMapper(amqpUrl, serviceName);
                var subscriber = new RestBusSubscriber(msgMapper);
                using (var host = new RestBusHost(subscriber, startup.Config))
                {
                    host.Start();
                    Console.WriteLine("Server started ... Ctrl-C to quit.");
                    Console.ReadLine();
                }
            }
        }
Esempio n. 4
0
        public IList <IDisposable> Start()
        {
            List <IDisposable> servers = new List <IDisposable>();

            //Initialize startup object
            var startup = new Startup();

            string baseAddress = null;

            //baseAddress = "http://localhost:9000/"; //Uncomment this line to also listen via HTTP on localhost:9000

            //Start WebAPI OWIN host
            servers.Add(WebApp.Start(url: baseAddress, startup: startup.Configuration));

            //Start RestBus Subscriber/host

            var amqpUrl     = ConfigurationManager.AppSettings["rabbitmqserver"]; //AMQP URI for RabbitMQ server
            var serviceName = "test";                                             //Uniquely identifies this service

            var msgMapper  = new BasicMessageMapper(amqpUrl, serviceName);
            var subscriber = new RestBusSubscriber(msgMapper);
            var host       = new RestBusHost(subscriber, startup.Config);

            host.Start();
            Console.WriteLine("Server started ... Ctrl-C to quit.");

            servers.Add(host);
            return(servers);
        }
Esempio n. 5
0
        public void Start <TContext>(IHttpApplication <TContext> application)
        {
            //TODO: Code a better way to prevent same server from starting twice.
            if (_disposables != null)
            {
                // The server has already started and/or has not been cleaned up yet
                throw new InvalidOperationException("Server has already started.");
            }
            _disposables = new Stack <IDisposable>();

            try
            {
                var information = (ServerInformation)Features.Get <IServerInformation>();

                if (information.Subscriber == null)
                {
                    throw new InvalidOperationException($"RestBus subscriber could not be found. To use the RestBus server, call app.{nameof(ServerExtensions.ConfigureRestBusServer)} in Startup.Configure method and specify a subscriber to use.");
                }

                //TODO: Add _logger properly

                var host = new RestBusHost <TContext>(information.Subscriber, application);
                _disposables.Push(host);

                //TODO: Make IApplicationLifeTime.Stopping to stop polling the queue.

                host.Start();

                foreach (var name in information.Subscriber.ConnectionNames)
                {
                    information.AddAddress(name);
                }
            }
            catch
            {
                Dispose();
                throw;
            }
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterOpenAuth();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Initialize ServiceStack application
            new AppHost().Init();


            //*** Start RestBus subscriber/host **//

            var amqpUrl = "amqp:localhost:5672"; //AMQP URL for RabbitMQ installation
            var serviceName = "madagascar"; //Uniquely identifies this service

            var msgMapper = new BasicMessageMapper(amqpUrl, serviceName);
            var subscriber = new RestBusSubscriber(msgMapper);
            restbusHost = new RestBusHost(subscriber);
            restbusHost.Start();

            //****//
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            new AppHost().Init();

            //*** Start RestBus subscriber/host **//

            var amqpUrl = "amqp:localhost:5672"; //AMQP URL for RabbitMQ installation
            var serviceName = "madagascar"; //Uniquely identifies this service

            var msgMapper = new BasicMessageMapper(amqpUrl, serviceName);
            var subscriber = new RestBusSubscriber(msgMapper);
            restbusHost = new RestBusHost(subscriber);
            restbusHost.Start();

            //****//
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterOpenAuth();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Initialize ServiceStack application
            new AppHost().Init();


            //*** Start RestBus subscriber/host **//

            var amqpUrl     = "amqp://localhost:5672"; //AMQP URL for RabbitMQ installation
            var serviceName = "samba";                 //Uniquely identifies this service

            var msgMapper  = new BasicMessageMapper(amqpUrl, serviceName);
            var subscriber = new RestBusSubscriber(msgMapper);

            restbusHost = new RestBusHost(subscriber);
            restbusHost.Start();

            //****//
        }