Esempio n. 1
0
        static MSMQQueueWrapper()
        {
            SocketServerConfiguration config = ServerConfigurationHelper.GetServerConfiguration();

            if (config.Queues.Count > 0)
            {
                QueuePath = config.Queues[0].QueuePath;
            }

            EnsureQueueExists(QueuePath);
        }
Esempio n. 2
0
        public SocketService()
        {
            SocketServerConfiguration config = ServerConfigurationHelper.GetServerConfiguration();

            if (config.Queues.Count > 0)
            {
                _messageServer = new CommandServer(config.Queues[0].QueueName, config.Queues[0].QueuePath);
            }

            _serverManager = new SocketManager(config);
            InitializeComponent();
        }
Esempio n. 3
0
        static MSMQQueueWrapper()
        {
            SocketServerConfiguration config = ServerConfigurationHelper.GetServerConfiguration();

            if (config.Queues.Count > 0)
            {
                QueuePath = config.Queues[0].QueuePath;
            }
            else
            {
                throw new Exception("No queues specified in configuration.");
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> Post([FromBody] RegisterOrderCommandModel registerOrderCommandModel)
        {
            var bus = BusConfigurator.ConfigureBus();

            var sendToUri = ServerConfigurationHelper.GetUri(RegisterOrderConstants.RegisterOrderServiceQueue);

            var endPoint = await bus.GetSendEndpoint(sendToUri);

            var registerOrderCommand = Mapper.Map <RegisterOrder>(registerOrderCommandModel);

            await endPoint.Send(registerOrderCommand);

            return(Ok());
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var appConfigurationRoot      = new AppConfigurationRootProvider().Get();
            var serverConfigurationHelper = new ServerConfigurationHelper(appConfigurationRoot);
            var bus = new BusConfigurator(serverConfigurationHelper).ConfigureBus((cfg, host) =>
            {
                cfg.ReceiveEndpoint(host, OrderNotificationConstants.OrderNotificationServiceQueue, e =>
                {
                    e.Consumer <OrderNotificationConsumer>();
                });
            });

            bus.Start();

            Console.WriteLine("Listening...", Color.Cyan);

            Console.ReadKey();

            bus.Stop();
        }
Esempio n. 6
0
        private void RegisterMessages()
        {
            var config
                = ServerConfigurationHelper.GetServerConfiguration();

            if (config != null)
            {
                foreach (MessageConfigurationElement messageConfiguration in config.Messages)
                {
                    Type t = ReflectionHelper.FindType(messageConfiguration.TypeName);
                    if (t != null)
                    {
                        // MessageFactory.Register(messageConfiguration.Name, t);
                    }
                    else
                    {
                        throw new Exception("Invalid message type specified in configuration");
                    }
                }
            }
        }
Esempio n. 7
0
        //protected virtual void OnClientRequestReceived(Guid clientId, RequestHeader header, object request)
        //{
        //    EventHandler<ClientRequestEventArgs> clientRequestReceived = ClientRequestReceived;
        //    if (clientRequestReceived != null)
        //    {
        //        var args = new ClientRequestEventArgs(clientId, header, request);
        //        clientRequestReceived(this, args);
        //    }
        //}

        /// <summary>
        /// Starts the server.
        /// </summary>
        public void StartServer()
        {
            SocketServerConfiguration configuration = null;

            try
            {
                configuration = ServerConfigurationHelper.GetServerConfiguration();
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString());
            }

            if (configuration != null)
            {
                MSMQQueueWrapper.QueueCommand(new ServerStartingCommand());

                _socketServer.StartServer(configuration.ListenPort);

                Logger.InfoFormat("Server started and listening on {0}", configuration.ListenPort);
            }
        }
Esempio n. 8
0
 public BusConfigurator(ServerConfigurationHelper serverConfigurationHelper)
 {
     ServerConfigurationHelper = serverConfigurationHelper;
 }
        /// <summary>
        /// Initializes the <see cref="ServiceHandlerLookup"/> class.
        /// </summary>
        static ServiceHandlerRepository()
        {
            SocketServerConfiguration config = ServerConfigurationHelper.GetServerConfiguration();

            Instance.LoadHandlers(config);
        }
Esempio n. 10
0
 public RegistrationController(ServerConfigurationHelper serverConfigurationHelper, BusConfigurator busConfigurator, IMapper mapper)
 {
     ServerConfigurationHelper = serverConfigurationHelper;
     BusConfigurator           = busConfigurator;
     Mapper = mapper;
 }