コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the BrokerQueueFactory class,
        /// </summary>
        /// <param name="persistName">tye persist name.</param>
        /// <param name="sharedData">indicating the shared data</param>
        public BrokerQueueFactory(string persistName, SharedData sharedData)
        {
            if (persistName == null)
            {
                persistName = string.Empty;
            }

            ParamCheckUtility.ThrowIfOutofRange(!string.IsNullOrEmpty(persistName) && !string.Equals("AzureQueue", persistName, StringComparison.OrdinalIgnoreCase), "persistName");
            this.thisLockObj           = new object();
            this.sessionId             = sharedData.BrokerInfo.SessionId;
            this.persistName           = persistName;
            this.sharedData            = sharedData;
            this.clientBrokerQueueDic  = new Dictionary <string, BrokerQueue>(StringComparer.OrdinalIgnoreCase);
            this.brokerQueueDispatcher = new BrokerQueueDispatcher(this.sessionId, !string.IsNullOrEmpty(persistName), sharedData);
#if MSMQ
            if (!string.IsNullOrEmpty(sharedData.BrokerInfo.AadUserSid) && !string.IsNullOrEmpty(sharedData.BrokerInfo.AadUserName))
            {
                BrokerTracing.TraceInfo($"[BrokerQueueFactory] .Ctor: Add AAD SID mapping from broker start info: {sharedData.BrokerInfo.AadUserSid}, {sharedData.BrokerInfo.AadUserName}.");
                MSMQ.MSMQPersist.SetAadSidEntry(sharedData.BrokerInfo.AadUserSid, sharedData.BrokerInfo.AadUserName);
            }
#endif
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
        /// <summary>
        /// Indicate the end of requeusts
        /// </summary>
        /// <param name="count">indicating the number of the messages</param>
        /// <param name="timeoutMs">indicating the timeout in MS</param>
        /// <param name="clientId">indicating the client id</param>
        public void EndRequests(int count, string clientId, int batchId, int timeoutThrottlingMs, int timeoutEOMMs)
        {
            ParamCheckUtility.ThrowIfOutofRange(count < 0, "count");
            ParamCheckUtility.ThrowIfOutofRange(timeoutThrottlingMs <= 0 && timeoutThrottlingMs != Timeout.Infinite, "timeoutThrottlingMs");
            ParamCheckUtility.ThrowIfOutofRange(timeoutEOMMs <= 0 && timeoutEOMMs != Timeout.Infinite, "timeoutEOMMs");
            ParamCheckUtility.ThrowIfNull(clientId, "clientId");
            ParamCheckUtility.ThrowIfTooLong(clientId.Length, "clientId", Constant.MaxClientIdLength, SR.ClientIdTooLong);
            ParamCheckUtility.ThrowIfNotMatchRegex(ParamCheckUtility.ClientIdValid, clientId, "clientId", SR.InvalidClientId);

            this.ThrowIfDisposed();
            this.CheckAuth();

            BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Information, 0, "[BrokerController] Receive EOM for Client {0}, Count = {1}", clientId, count);
            try
            {
                #region Debug Failure Test
                SimulateFailure.FailOperation(1);
                #endregion

                BrokerClient brokerClient = this.GetClient(clientId);
                FrontEndBase frontendBase = brokerClient.GetDuplexFrontEnd();

                WaitOnThrottling(frontendBase, timeoutThrottlingMs);

                // Then handle the EOM which waits until all requests are stored. Use user specified EndRequests timeout for this
                brokerClient.EndOfMessage(count, batchId, timeoutEOMMs);

                #region Debug Failure Test
                SimulateFailure.FailOperation(2);
                #endregion
            }
            catch (Exception e)
            {
                BrokerTracing.TraceError("[BrokerController] EOM failed for client {0}: {1}", clientId, e);
                throw TranslateException(e);
            }
        }