private async Task AcceptMessageEventAsync(MessageEventArgs msgEv, FlowBindings.FlowBindingElement binding) { try { Message rxMessage = SolaceNativeMsgAdapter.ConvertFromNativeMsg(msgEv.Message); bool continueDelivery = requestMgr.HandleIncoming(rxMessage); // If continueDelivery is false, the message was handled by the requestMgr so we drop it. if (continueDelivery && binding != null) { await binding.DispatchMessageAsync(rxMessage).ConfigureAwait(false); } else if (continueDelivery && binding == null) { // There is no callback on which to forward the message to, so dispatch // the message to the default session callback. await defaultAppMsgQueue.SendAsync(rxMessage).ConfigureAwait(false); } } finally { msgEv.Message.Dispose(); } }
/// <summary> /// Sends messages asynchronously. For PersistentMessage types, the /// MessageCorrelationContext provides caller to know if the message was /// acknowledge or not by the Solace Event Broker. /// </summary> /// <param name="message"></param> /// <returns></returns> public Task <MessageCorrelationContext> SendAsync(Message message) { using (var solaceMsg = SolaceNativeMsgAdapter.ConvertToNativeMsg(message)) { var msgCtx = new MessageCorrelationContext(message, message.CorrelationId); var tcs = new TaskCompletionSource <MessageCorrelationContext>(); solaceMsg.CorrelationKey = new MessageTaskPair(msgCtx, tcs); ReturnCode rc; try { rc = session.Send(solaceMsg); } catch (Exception e) { solaceMsg.Dispose(); throw new MessagingException(e.Message, e); } switch (rc) { case ReturnCode.SOLCLIENT_OK: case ReturnCode.SOLCLIENT_IN_PROGRESS: // OK break; default: throw new MessagingException("Send failure: " + rc.ToString()); } if (!message.IsPersistent) { // There will be no ack, immediately consider it acknowledged (complete synchronously) tcs.SetResult(msgCtx); } return(tcs.Task); } }