/// <summary> /// Initiates an asynchronous attempt to reliably deliver a message to a target endpoint. /// </summary> /// <param name="targetEP">The target endpoint.</param> /// <param name="query">The query message.</param> /// <param name="confirmDelivery">Indicates whether or not the delivery should be confirmed.</param> /// <param name="callback">The delegate to be called when the operation completes (or <c>null</c>).</param> /// <param name="state">Application defined state.</param> /// <returns>The <see cref="IAsyncResult" /> instance to be used to track the operation's progress.</returns> /// <remarks> /// <note> /// Note that the operation doesn't complete until the message has been safely /// submitted to the queuing message implemented by the class. This is done /// to ensure that the message is actually accepted by the messenger and /// also as a flow control mechanism. /// </note> /// <note> /// Every successful call to <see cref="BeginDelivery(MsgEP,Msg,bool,AsyncCallback,object)" /> must eventually /// be followed by a call to <see cref="EndDelivery" />. /// </note> /// </remarks> public IAsyncResult BeginDelivery(MsgEP targetEP, Msg query, bool confirmDelivery, AsyncCallback callback, object state) { if (!router.IsOpen) { throw new ArgumentException(ReliableMessenger.RouterClosedMsg); } var confirmation = new DeliveryConfirmation(); var deliverAR = new AsyncResult(null, callback, state); confirmation.TargetEP = targetEP; confirmation.Query = query; confirmation.State = new QueryState(deliverAR, confirmDelivery && confirmCallback != null); router.BeginQuery(targetEP, query, onEndpointDelivery, confirmation); deliverAR.Started(); return(deliverAR); }
/// <summary> /// Initiates an asynchronous attempt to reliably deliver a message to a cluster. /// </summary> /// <param name="topologyProvider">The cluster's topology provider.</param> /// <param name="key">The optional topology key.</param> /// <param name="query">The query message.</param> /// <param name="confirmDelivery">Indicates whether or not the delivery should be confirmed.</param> /// <param name="callback">The delegate to be called when the operation completes (or <c>null</c>).</param> /// <param name="state">Application defined state.</param> /// <returns>The <see cref="IAsyncResult" /> instance to be used to track the operation's progress.</returns> /// <remarks> /// <note> /// The operation doesn't complete until the message has been safely /// submitted to the queuing message implemented by the class. This is done /// to ensure that the message is actually accepted by the messenger and /// also as a flow control mechanism. /// </note> /// <note> /// Every successful call to <see cref="BeginDelivery(MsgEP,Msg,bool,AsyncCallback,object)" /> must eventually /// be followed by a call to <see cref="EndDelivery" />. /// </note> /// </remarks> public IAsyncResult BeginDelivery(ITopologyProvider topologyProvider, object key, Msg query, bool confirmDelivery, AsyncCallback callback, object state) { if (!router.IsOpen) { throw new ArgumentException(ReliableMessenger.RouterClosedMsg); } var confirmation = new DeliveryConfirmation(); var deliverAR = new AsyncResult(null, callback, state); confirmation.TargetEP = topologyProvider.ClusterEP; confirmation.Query = query; confirmation.TopologyID = topologyProvider.InstanceID; confirmation.TopologyInfo = topologyProvider.SerializeClient(); confirmation.TopologyParam = null; confirmation.State = new QueryState(deliverAR, confirmDelivery && confirmCallback != null, topologyProvider); topologyProvider.BeginQuery(key, query, onClusterDelivery, confirmation); deliverAR.Started(); return(deliverAR); }