Beispiel #1
0
 private IEnumerable<int> CreateTopicOnBroker(string topic, Broker broker)
 {
     var brokerAdminEndpoint = broker.BrokerInfo.AdminAddress.ToEndPoint();
     var adminRemotingClient = new SocketRemotingClient(brokerAdminEndpoint, _nameServerController.Setting.SocketSetting).Start();
     var requestData = _binarySerializer.Serialize(new CreateTopicRequest(topic));
     var remotingRequest = new RemotingRequest((int)BrokerRequestCode.CreateTopic, requestData);
     var remotingResponse = adminRemotingClient.InvokeSync(remotingRequest, 30000);
     if (remotingResponse.Code != ResponseCode.Success)
     {
         throw new Exception(string.Format("AutoCreateTopicOnBroker failed, errorMessage: {0}", Encoding.UTF8.GetString(remotingResponse.Body)));
     }
     adminRemotingClient.Shutdown();
     return _binarySerializer.Deserialize<IEnumerable<int>>(remotingResponse.Body);
 }