示例#1
0
        private void ReceiveAckHandleReply()
        {
            var message = Receive();

            if (message == null)
            {
                return;
            }
            Ack(message);

            try
            {
                var messageBody = Json.Deserialize(message.Body);
                _log.Debug("Received message: {0}", messageBody);
                var request  = new JsonTransportRequest(EndpointFor(message), messageBody);
                var response = _handler.HandleRequest(request);
                Reply(message, response);
            }
            catch (Exception e)
            {
                var response = JsonTransportResponse.Error(e.Message);
                _log.Error(e);
                Reply(message, response);
            }
        }
示例#2
0
        private void Reply(IReceivedMessage message, JsonTransportResponse response)
        {
            var reply   = message.CreateReply();
            var headers = AmqpRpc.CreateHeaders(null, response.Status);

            reply.Properties.Headers = headers;
            _log.Debug("Sending reply: {0}", response.Body);
            reply.Body = Json.Serialize(response.Body);
            reply.From = null;
            _messaging.Send(reply);
        }
        public JsonTransportResponse HandleRequest(JsonTransportRequest request)
        {
            switch (request.Endpoint)
            {
            case "query_aggregate_digests":
                return(HandleQueryAggregateDigestsRequest(request));

            case "query_entity_versions":
                return(HandleQueryEntityVersionsRequest(request));

            case "invoke":
                return(HandleActionInvocation(request));

            case "retrieve_content":
                return(HandleRetrieveContent(request));

            default:
                return(JsonTransportResponse.NotFound("Endpoint '" + request.Endpoint + @"' not implemented"));
            }
        }
示例#4
0
 private void Reply(IReceivedMessage message, JsonTransportResponse response)
 {
     var reply = message.CreateReply();
     var headers = AmqpRpc.CreateHeaders(null, response.Status);
     reply.Properties.Headers = headers;
     _log.Debug("Sending reply: {0}", response.Body);
     reply.Body = Json.Serialize(response.Body);
     reply.From = null;
     _messaging.Send(reply);
 }