/// <summary> /// Get responses /// </summary> /// <param name="action">indicating the action</param> /// <param name="clientData">indicating the client data</param> /// <param name="resetToBegin">indicating the get response position</param> /// <param name="count">indicating the count</param> /// <param name="clientId">indicating the client id</param> void IResponseService.GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId) { if (this.useAzureQueue) { string azureResponseQueueUri; string azureResponseBlobUri; this.controller.GetResponsesAQ(action, clientData, resetToBegin, count, clientId, this.sessionHash, out azureResponseQueueUri, out azureResponseBlobUri); // then retrieve the responses async from the azure queue proxy if (!this.azureQueueProxy.IsResponseClientInitialized && !string.IsNullOrEmpty(azureResponseQueueUri) && !string.IsNullOrEmpty(azureResponseBlobUri)) { this.azureQueueProxy.InitResponseClient(azureResponseQueueUri, azureResponseBlobUri); } // check if there is already a handler with the same action and clientData foreach (IResponseHandler h in this.handlers) { if (h.Action().Equals(action, StringComparison.InvariantCulture) && h.ClientData().Equals(clientData, StringComparison.InvariantCultureIgnoreCase)) { return; } } AzureQueueResponseHandler handler = new AzureQueueResponseHandler(this.azureQueueProxy, action, clientData, resetToBegin, count, clientId, this.callback, this); this.handlers.Add(handler); handler.Completed += new EventHandler(this.HandlerCompleted); } else { HttpResponseHandler handler = new HttpResponseHandler(this.controller, action, clientData, resetToBegin, count, clientId, this.callback, this); this.handlers.Add(handler); handler.Completed += new EventHandler(this.HandlerCompleted); } }
/// <summary> /// Pull responses /// </summary> /// <param name="position">indicating the position</param> /// <param name="count">indicating the count</param> /// <returns>broker response messages</returns> public BrokerResponseMessages PullResponses(GetResponsePosition position, int count) { this.result = new PullResponseMessage(count, this.Queue, this.ConvertMessage, this.ResetTimeout, this.SharedData); if (position == GetResponsePosition.Begin) { this.Queue.ResetResponsesCallback(); this.ResponsesCount = 0; } BrokerResponseMessages responseMessages; if (this.Queue.RegisterResponsesCallback(this.result.ReceiveResponse, OperationContext.Current.IncomingMessageVersion, GenerateResponseActionFilter(this.Action), count, null)) { this.result.CompleteEvent.WaitOne(); responseMessages = this.result.Message; } else { responseMessages = this.result.Message; responseMessages.EOM = true; } BrokerTracing.TraceInfo("[PullResponsesHandler] Pull responses finished, Count = {0}", responseMessages.SOAPMessage.Length); this.IncreaseResponsesCount(responseMessages.SOAPMessage.Length); return(responseMessages); }
public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, string clientId) { return(new BrokerResponseMessages() { EOM = true }); }
/// <summary> /// For Java to pull the responses /// </summary> /// <param name="action">indicating the action</param> /// <param name="position">indicating the position</param> /// <param name="count">indicating the count</param> /// <param name="clientId">indicating the client id</param> /// <returns>returns the responses messages</returns> public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, string clientId) { try { ParamCheckUtility.ThrowIfOutofRange(count <= 0, "count"); ParamCheckUtility.ThrowIfNull(clientId, "clientId"); ParamCheckUtility.ThrowIfTooLong(clientId.Length, "clientId", Constant.MaxClientIdLength, SR.ClientIdTooLong); ParamCheckUtility.ThrowIfNotMatchRegex(ParamCheckUtility.ClientIdValid, clientId, "clientId", SR.InvalidClientId); BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Information, 0, "[BrokerController] PullResponses: Action = {0}, Position = {1}, Count = {2}", action, position, count); this.ThrowIfDisposed(); this.CheckAuth(); #region Debug Failure Test SimulateFailure.FailOperation(1); #endregion return(this.GetClient(clientId).PullResponses(action, position, count, GetMessageVersion())); } catch (Exception e) { BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, "[BrokerController] PullResponses Failed: {0}", e); throw TranslateException(e); } }
BrokerResponseMessages IController.PullResponses(string action, GetResponsePosition position, int count, string clientId) { this.ThrowIfClosed(); return(this.RenewFrontendInstanceIfDisposed <BrokerResponseMessages>(clientId, delegate() { return this.frontend.PullResponses(action, position, count, clientId); })); }
void IResponseService.GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId) { this.ThrowIfClosed(); this.RenewFrontendInstanceIfDisposed <object>(clientId, delegate() { this.frontend.GetResponses(action, clientData, resetToBegin, count, clientId); return(null); }); }
public Task <(string azureResponseQueueUri, string azureResponseBlobUr)> GetResponsesAQAsync( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash) { return(this.StartRequestAsync <(string, string)>(nameof(this.GetResponsesAQ), action, clientData, resetToBegin, count, clientId, sessionHash)); }
public IAsyncResult BeginGetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, AsyncCallback callback, object asyncState) { return(this.Channel.BeginGetResponsesAQ(action, clientData, resetToBegin, count, clientId, sessionHash, callback, asyncState)); }
public IAsyncResult BeginGetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, System.AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public void GetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, out string azureResponseQueueUri, out string azureResponseBlobUri) { throw new NotImplementedException(); }
public void GetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, out string azureResponseQueueUri, out string azureResponseBlobUri) { azureResponseQueueUri = "queue"; azureResponseBlobUri = "blob"; }
public void GetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, out string azureResponseQueueUri, out string azureResponseBlobUri) { IAsyncResult result = this.Channel.BeginGetResponsesAQ(action, clientData, resetToBegin, count, clientId, sessionHash, null, null); this.Channel.EndGetResponsesAQ(out azureResponseQueueUri, out azureResponseBlobUri, result); }
/// <summary> /// Retrieves another window of response messages /// </summary> /// <param name="reset">Whether to reset from the start</param> /// <param name="messageCount">Number of messages to return</param> private void GetMoreResponses(bool reset, int messageCount) { GetResponsePosition position = reset ? GetResponsePosition.Begin : GetResponsePosition.Current; try { // Bug 22175: We must avoid to use the sync version of GetResponses // here because it is within a lock on an I/O completion thread if (this.responseServiceAsyncClient != null) { this.responseServiceAsyncClient.BeginGetResponses( this.action, this.callbackManagerId, position, messageCount, this.clientId, this.GetResponseCallback, null); } else { // In certain cases like inproc broker, we will still need // the sync version but it won't trigger the bug because there // is no pending I/O here. this.responseServiceClient.GetResponses( this.action, this.callbackManagerId, position, messageCount, this.clientId); // Reset the heartbeat since operation just succeeded this.session.ResetHeartbeat(); } } catch (FaultException <SessionFault> e) { throw Utility.TranslateFaultException(e); } if (messageCount == Constant.GetResponse_All) { Interlocked.Exchange(ref messageCount, int.MaxValue); } else { Interlocked.Add(ref this.outstandingRequestCount, messageCount); } }
public void GetResponsesAQ( string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, out string azureResponseQueueUri, out string azureResponseBlobUri) { var res = this.GetResponsesAQAsync(action, clientData, resetToBegin, count, clientId, sessionHash).GetAwaiter().GetResult(); azureResponseQueueUri = res.azureResponseQueueUri; azureResponseBlobUri = res.azureResponseBlobUr; }
/// <summary> /// Get responses /// </summary> /// <param name="action">indicating the action</param> /// <param name="clientData">indicating the client data</param> /// <param name="resetToBegin">indicating the get response position</param> /// <param name="count">indicating the count</param> /// <param name="clientId">indicating the client id</param> void IResponseService.GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId) { lock (this.lockObjectToProtectHandlers) { if (this.handlers == null) { throw new ObjectDisposedException("WebBrokerFrontendForGetResponse"); } HttpWebRequest request = SOAWebServiceRequestBuilder.GenerateGetResponseWebRequest(this.brokerNode, this.sessionId, clientId, this.credential, action, clientData, count, resetToBegin == GetResponsePosition.Begin); WebResponseHandler handler = new WebResponseHandler(request, clientData, this.callback); this.handlers.Add(handler); handler.Completed += new EventHandler(Handler_Completed); } }
/// <summary> /// Get more responses /// </summary> /// <param name="position">indicating the position</param> /// <param name="count">indicating the count</param> /// <param name="callbackInstance">indicating the callback instance</param> public void GetResponses(GetResponsePosition position, int count, IResponseServiceCallback callbackInstance) { if (position == GetResponsePosition.Begin) { this.ResponsesCount = 0; if (this.IsSessionFailed()) { IResponseServiceCallback callback = callbackInstance; this.ReplyFaultMessage(callback, FrontEndFaultMessage.GenerateFaultMessage(null, this.Version, SOAFaultCode.Broker_SessionFailure, SR.SessionFailure), this.clientData); this.ReplyEndOfMessage(callback, this.clientData); return; } if (this.cacheBrokerQueueItem) { // ACK the items as they were failed to send back to client lock (this.lockCacheItemList) { this.Queue.AckResponses(this.cachedItemList, false); this.cachedItemList = new List <BrokerQueueItem>(); } } this.Queue.ResetResponsesCallback(); } else { if (this.cacheBrokerQueueItem) { // ACK the items as they were succeeded to send back to client lock (this.lockCacheItemList) { this.Queue.AckResponses(this.cachedItemList, true); this.cachedItemList = new List <BrokerQueueItem>(); } } } ResponseActionFilter filter = GenerateResponseActionFilter(this.Action); this.lastResponseServiceCallback = callbackInstance; if (!this.Queue.RegisterResponsesCallback(this.ReceiveResponse, this.Version, filter, count, new object[] { this.lastResponseServiceCallback, this.clientData })) { this.ReplyEndOfMessage(this.lastResponseServiceCallback, this.clientData); } }
/// <summary> /// Get response from the Azure storage /// </summary> /// <param name="action">indicating the action</param> /// <param name="clientData">indicating the client data</param> /// <param name="resetToBegin">indicating the position</param> /// <param name="count">indicating the count</param> /// <param name="clientId">indicating the client id</param> /// <param name="sessionHash">specifying the session object hash</param> /// <param name="azureResponseQueueUri">return the Azure storage queue SAS Uri</param> /// <param name="azureResponseBlobUri">return the Azure storage blob container SAS Uri</param> public void GetResponsesAQ(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, int sessionHash, out string azureResponseQueueUri, out string azureResponseBlobUri) { //create the azure response queue if not exist AzureQueueProxy queueProxy = this.callbackInstance as AzureQueueProxy; if (queueProxy == null) { BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, "[BrokerController] The callback instance is not AzureQueueProxy"); azureResponseQueueUri = null; azureResponseBlobUri = null; return; } queueProxy.AddResponseQueues(clientData, sessionHash); azureResponseQueueUri = queueProxy.ResponseClientUris[sessionHash].Item1; azureResponseBlobUri = queueProxy.ResponseClientUris[sessionHash].Item2; this.GetResponses(action, clientData, resetToBegin, count, clientId); }
public HttpResponseHandler( IController controller, string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, IResponseServiceCallback callback, BrokerResponseServiceClient responseClient) { this.controller = controller; this.action = action; this.clientData = clientData; this.resetToBegin = resetToBegin; this.count = count; this.clientId = clientId; this.callback = callback; this.responseClient = responseClient; this.HttpResponseThread = new Thread(this.HttpGetResponseThread); this.HttpResponseThread.IsBackground = true; this.HttpResponseThread.Start(); }
/// <summary> /// Get responses from client /// </summary> /// <param name="action">indicating the action</param> /// <param name="clientData">indicating the client data</param> /// <param name="resetToBegin">indicating the position</param> /// <param name="count">indicating the count</param> /// <param name="clientId">indicating the client id</param> public void GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId) { try { BrokerTracing.TraceVerbose("[BrokerController] GetResponses is called for Client {0}.", clientId); ParamCheckUtility.ThrowIfOutofRange(count <= 0 && count != -1, "count"); ParamCheckUtility.ThrowIfNull(clientId, "clientId"); ParamCheckUtility.ThrowIfTooLong(clientId.Length, "clientId", Constant.MaxClientIdLength, SR.ClientIdTooLong); ParamCheckUtility.ThrowIfNotMatchRegex(ParamCheckUtility.ClientIdValid, clientId, "clientId", SR.InvalidClientId); BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Information, 0, "[BrokerController] GetResponses for Client {2}, Count = {0}, Position = {1}", count, resetToBegin, clientId); this.ThrowIfDisposed(); this.CheckAuth(); // Try to get callback instance for inprocess broker IResponseServiceCallback callbackInstance = this.callbackInstance; // If callback instance is null, get callback instance from operation context if (callbackInstance == null) { callbackInstance = OperationContext.Current.GetCallbackChannel <IResponseServiceCallback>(); } this.GetClient(clientId).GetResponses(action, clientData, resetToBegin, count, callbackInstance, GetMessageVersion()); #region Debug Failure Test SimulateFailure.FailOperation(1); #endregion BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Information, 0, "[BrokerController] GetResponses for Client {0} Succeeded.", clientId); } catch (Exception e) { BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, "[BrokerController] GetResponses for Client {1} Failed: {0}", e, clientId); throw TranslateException(e); } }
/// <summary> /// Pull responses for Java clients /// </summary> /// <param name="action">indicating the action</param> /// <param name="position">indicating the position</param> /// <param name="count">indicating the count</param> /// <returns>returns the responses messages</returns> /// <param name="version">indicating the message version</param> public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, MessageVersion version) { this.CheckDisconnected(); this.timeoutManager.ResetTimeout(); if (this.responsesClient is PullResponsesHandler) { PullResponsesHandler handler = this.responsesClient as PullResponsesHandler; if (handler.Match(action)) { return(handler.PullResponses(position, count)); } } if (this.responsesClient != null) { this.responsesClient.Dispose(); } this.responsesClient = new PullResponsesHandler(this.queue, action, this.timeoutManager, this.observer, this.sharedData, version); return((this.responsesClient as PullResponsesHandler).PullResponses(position, count)); }
public AzureQueueResponseHandler( AzureQueueProxy azureQueueProxy, string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, IResponseServiceCallback callback, BrokerResponseServiceClient responseClient) { this.action = action; this.clientData = clientData; this.resetToBegin = resetToBegin; this.count = count; this.clientId = clientId; this.callback = callback; this.responseClient = responseClient; this.azureQueueProxy = azureQueueProxy; this.AzureQueueResponseThread = new Thread(new ThreadStart(this.GetResponseThread)); this.AzureQueueResponseThread.IsBackground = true; this.AzureQueueResponseThread.Start(); }
/// <summary> /// Get responses /// </summary> /// <param name="action">indicating the action</param> /// <param name="clientData">indicating the client data</param> /// <param name="resetToBegin">indicating the position</param> /// <param name="count">indicating the count</param> /// <param name="callbackInstance">indicating the callback instance</param> /// <param name="version">indicating the message version</param> public void GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, IResponseServiceCallback callbackInstance, MessageVersion version) { this.CheckDisconnected(); this.timeoutManager.ResetTimeout(); if (this.responsesClient is GetResponsesHandler) { GetResponsesHandler handler = this.responsesClient as GetResponsesHandler; if (handler.Matches(action, clientData)) { handler.GetResponses(resetToBegin, count, callbackInstance); return; } } if (this.responsesClient != null) { this.responsesClient.Dispose(); } this.responsesClient = new GetResponsesHandler(this.queue, action, clientData, this.clientId, this.timeoutManager, this.observer, this.sharedData, version); (this.responsesClient as GetResponsesHandler).GetResponses(resetToBegin, count, callbackInstance); }
public Task <BrokerResponseMessages> PullResponsesAsync(string action, GetResponsePosition position, int count, string clientId) { return(this.StartRequestAsync <BrokerResponseMessages>(nameof(this.PullResponses), action, position, count, clientId)); }
public IAsyncResult BeginPullResponses(string action, GetResponsePosition position, int count, string clientId, AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public IAsyncResult BeginGetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId, AsyncCallback callback, object state) { return(this.Channel.BeginGetResponses(action, clientData, resetToBegin, count, clientId, callback, state)); }
public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, string clientId) { IAsyncResult result = this.Channel.BeginPullResponses(action, position, count, clientId, null, null); return(this.Channel.EndPullResponses(result)); }
BrokerResponseMessages IController.PullResponses(string action, GetResponsePosition position, int count, string clientId) { throw new NotSupportedException(); }
public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, string clientId) { throw new NotImplementedException(); }
public void GetResponses(string action, string clientData, GetResponsePosition resetToBegin, int count, string clientId) { this.EndGetResponses(this.BeginGetResponses(action, clientData, resetToBegin, count, clientId, null, null)); }
public BrokerResponseMessages PullResponses(string action, GetResponsePosition position, int count, string clientId) { return(this.PullResponsesAsync(action, position, count, clientId).GetAwaiter().GetResult()); }