public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); int overload = 1; bool subscribed = false; string exceptionMessage = null; try { NCache nCache = clientManager.CmdExecuter as NCache; var operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); if (command.commandVersion < 1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, command.clientLastViewId.ToString(CultureInfo.InvariantCulture)); } CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress); if (nCache != null) { _command = command.subscribeTopicCommand; SubscriptionInfo subscriptionInfo = new SubscriptionInfo() { SubscriptionId = _command.subscriptionName, ClientId = clientManager.ClientID, Type = (SubscriptionType)_command.pubSubType, SubPolicyType = (SubscriptionPolicyType)_command.subscriptionPolicy, CreationTime = _command.creationTime, Expiration = _command.expirationTime }; SubscriptionOperation subOperation = new SubscriptionOperation(_command.topicName, TopicOperationType.Subscribe, subscriptionInfo); subscribed = nCache.Cache.TopicOpertion(subOperation, operationContext); stopWatch.Stop(); //Common.Protobuf.Response response = new Common.Protobuf.Response(); Common.Protobuf.SubscribeTopicResponse subscribeTopicResponse = new Common.Protobuf.SubscribeTopicResponse(); subscribeTopicResponse.success = subscribed; if (clientManager.ClientVersion >= 5000) { Common.Util.ResponseHelper.SetResponse(subscribeTopicResponse, command.requestID, command.commandID); _serializedResponsePackets.Add(Common.Util.ResponseHelper.SerializeResponse(subscribeTopicResponse, Common.Protobuf.Response.Type.SUBSCRIBE_TOPIC)); } else { //PROTOBUF:RESPONSE Common.Protobuf.Response response = new Common.Protobuf.Response(); response.subscribeTopicResponse = subscribeTopicResponse; Common.Util.ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.SUBSCRIBE_TOPIC); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } } } catch (Exception exc) { exceptionMessage = exc.ToString(); _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.CreateTopicSubscriptoin); log.GenerateSubscribeToTopicAPILogItem(_command.topicName, (SubscriptionType)_command.pubSubType, executionTime, clientManager.ClientID, clientManager.ClientIP, overload, subscribed, exceptionMessage, APIClassNames.TOPIC); } } catch { } } }