public async Task SendRequestToProcessorAsync(string id, CreateRequest createRequest) { var msgPayload = new QueueRequestMessage { Id = id, Content = createRequest.Content }; var msg = new OutgoingMqEnvelop <QueueRequestMessage> { Message = new MqMessage <QueueRequestMessage>(msgPayload), PublishTarget = new PublishTarget { Exchange = _options.QueueExchange, Routing = createRequest.ProcRouting ?? _options.QueueRoutingKey } }; _mqPublisher.Publish(msg); if (createRequest.CallbackRouting != null) { var callBackRoutingKey = GetCallbackRoutingKey(id); await callBackRoutingKey.SetAsync(createRequest.CallbackRouting); } }
/// <summary> /// Publishes message /// </summary> public static void Publish <T>(this IMqPublisher publisher, T msg) where T : class { if (publisher == null) { throw new ArgumentNullException(nameof(publisher)); } if (msg == null) { throw new ArgumentNullException(nameof(msg)); } publisher.Publish(new OutgoingMqEnvelop <T> { Message = new MqMessage <T>(msg) }); }
void SendCallbackMessage(string callbackRouting, ChangeStatusCallbackMessage msg) { try { _mqPublisher.Publish(new OutgoingMqEnvelop <ChangeStatusCallbackMessage> { PublishTarget = new PublishTarget { Exchange = _callbackQueue, Routing = callbackRouting }, Message = new MqMessage <ChangeStatusCallbackMessage>(msg) }); } catch (Exception e) { Log.Error("Can't send callback message", e).Write(); } }
public IActionResult Post([FromQuery] string queue) { Debug.WriteLine("====>>>"); var msg = new OutgoingMqEnvelop <string> { PublishTarget = new PublishTarget { Routing = queue }, Message = new MqMessage <string>("foo") }; _publisher.Publish(msg); return(Ok()); }
/// <summary> /// Publishes message in queue /// </summary> public static void PublishToQueue <T>(this IMqPublisher publisher, T msg, string queueName) where T : class { if (publisher == null) { throw new ArgumentNullException(nameof(publisher)); } if (msg == null) { throw new ArgumentNullException(nameof(msg)); } publisher.Publish(new OutgoingMqEnvelop <T> { PublishTarget = new PublishTarget { Routing = queueName }, Message = new MqMessage <T>(msg) }); }