Exemplo n.º 1
0
        private void MessageReceived(ClientSocketBase <TmqMessage> client, TmqMessage message)
        {
            if (message.Type == MessageType.Client && message.ContentType == ModelTypes.ConsumerRequest)
            {
                ConsumerRequest request = message.GetJsonContent <ConsumerRequest>().Result;
                Console.WriteLine($"Consumer request received: {request.Guid}");

                ProducerResponse model = new ProducerResponse();
                model.RequestGuid  = request.Guid;
                model.ResponseGuid = Guid.NewGuid().ToString();

                TmqMessage response = message.CreateResponse();
                response.ContentType = ModelTypes.ProducerResponse;
                response.SetJsonContent(model);
                TmqClient tmq = (TmqClient)client;
                tmq.Send(response);
            }
        }