protected void SendMessage <T>(T msg, string endpoint) { if (endpoint.StartsWith("http://") || Endpoint.StartsWith("https://")) { IServiceClient sc = ServiceClient.Create(endpoint); var rt = sc.CallService <object>(msg); } else if (endpoint.StartsWith("sql://")) { this.Context.GetService <IMessageBus>().Send(endpoint, msg); } else { IMessageConsumer <T> h = Context.GetService <IMessageConsumer <T> >(endpoint); h.Handle(msg); } }
public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body) { logger.LogDebug("got rabbitq message"); if (!consumer.CanHandle()) { this.Model.BasicNack(deliveryTag, false, true); } else { try { consumer.Handle(JsonUtil.FromBytes <Message>(body)); this.Model.BasicAck(deliveryTag, false); } catch (Exception ex) { logger.LogError(ex, "Unable to handle message"); this.Model.BasicNack(deliveryTag, false, true); } } }