Esempio n. 1
0
        public bool IsEqualsWith(BrokerInfo other)
        {
            if (other == null)
            {
                return(false);
            }

            return(BrokerName == other.BrokerName &&
                   GroupName == other.GroupName &&
                   ClusterName == other.ClusterName &&
                   BrokerRole == other.BrokerRole &&
                   ProducerAddress == other.ProducerAddress &&
                   ConsumerAddress == other.ConsumerAddress &&
                   AdminAddress == other.AdminAddress);
        }
Esempio n. 2
0
        public bool IsEqualsWith(BrokerInfo other)
        {
            if (other == null)
            {
                return false;
            }

            return BrokerName == other.BrokerName
                && GroupName == other.GroupName
                && ClusterName == other.ClusterName
                && BrokerRole == other.BrokerRole
                && ProducerAddress == other.ProducerAddress
                && ConsumerAddress == other.ConsumerAddress
                && AdminAddress == other.AdminAddress;
        }
Esempio n. 3
0
 public BrokerConnection(BrokerInfo brokerInfo, SocketRemotingClient remotingClient, SocketRemotingClient adminRemotingClient)
 {
     _brokerInfo = brokerInfo;
     _remotingClient = remotingClient;
     _adminRemotingClient = adminRemotingClient;
 }
Esempio n. 4
0
        public BrokerSetting(bool isMessageStoreMemoryMode = false, string chunkFileStoreRootPath = @"c:\equeue-store", int messageChunkDataSize = 1024 * 1024 * 1024, int chunkFlushInterval = 100, int chunkCacheMaxPercent = 75, int chunkCacheMinPercent = 40, int maxLogRecordSize = 5 * 1024 * 1024, int chunkWriteBuffer = 128 * 1024, int chunkReadBuffer = 128 * 1024, bool syncFlush = false, bool enableCache = true, int messageChunkLocalCacheSize = 300000, int queueChunkLocalCacheSize = 10000)
        {
            BrokerInfo = new BrokerInfo(
                "DefaultBroker",
                "DefaultGroup",
                "DefaultCluster",
                BrokerRole.Master,
                new IPEndPoint(SocketUtils.GetLocalIPV4(), 5000).ToAddress(),
                new IPEndPoint(SocketUtils.GetLocalIPV4(), 5001).ToAddress(),
                new IPEndPoint(SocketUtils.GetLocalIPV4(), 5002).ToAddress());

            NameServerList = new List<IPEndPoint>()
            {
                new IPEndPoint(SocketUtils.GetLocalIPV4(), 9493)
            };

            NotifyWhenMessageArrived = true;
            RegisterBrokerToNameServerInterval = 1000 * 5;
            DeleteMessagesInterval = 1000 * 10;
            DeleteQueueMessagesInterval = 1000 * 10;
            DeleteMessageIgnoreUnConsumed = true;
            PersistConsumeOffsetInterval = 1000 * 1;
            CheckBlockingPullRequestMilliseconds = 1000 * 1;
            ProducerExpiredTimeout = 1000 * 10;
            ConsumerExpiredTimeout = 1000 * 10;
            RemoveConsumerWhenDisconnect = true;
            AutoCreateTopic = true;
            TopicDefaultQueueCount = 4;
            TopicMaxQueueCount = 256;
            MessageMaxSize = 1024 * 1024 * 4;
            MessageWriteQueueThreshold = 2 * 10000;
            IsMessageStoreMemoryMode = isMessageStoreMemoryMode;
            FileStoreRootPath = chunkFileStoreRootPath;
            LatestMessageShowCount = 100;
            MessageChunkConfig = new ChunkManagerConfig(
                Path.Combine(chunkFileStoreRootPath, @"message-chunks"),
                new DefaultFileNamingStrategy("message-chunk-"),
                messageChunkDataSize,
                0,
                0,
                chunkFlushInterval,
                enableCache,
                syncFlush,
                Environment.ProcessorCount * 8,
                maxLogRecordSize,
                chunkWriteBuffer,
                chunkReadBuffer,
                chunkCacheMaxPercent,
                chunkCacheMinPercent,
                1,
                5,
                messageChunkLocalCacheSize,
                true,
                true);
            QueueChunkConfig = new ChunkManagerConfig(
                Path.Combine(chunkFileStoreRootPath, @"queue-chunks"),
                new DefaultFileNamingStrategy("queue-chunk-"),
                0,
                12,
                1000000,
                chunkFlushInterval,
                enableCache,
                syncFlush,
                Environment.ProcessorCount * 2,
                12,
                chunkWriteBuffer,
                chunkReadBuffer,
                chunkCacheMaxPercent,
                chunkCacheMinPercent,
                1,
                5,
                queueChunkLocalCacheSize,
                false,
                false);
        }
Esempio n. 5
0
        private BrokerConnection BuildAndStartBrokerConnection(BrokerInfo brokerInfo)
        {
            IPEndPoint brokerEndpoint;
            if (_producer != null)
            {
                brokerEndpoint = brokerInfo.ProducerAddress.ToEndPoint();
            }
            else if (_consumer != null)
            {
                brokerEndpoint = brokerInfo.ConsumerAddress.ToEndPoint();
            }
            else
            {
                throw new Exception("ClientService must set producer or consumer.");
            }
            var brokerAdminEndpoint = brokerInfo.AdminAddress.ToEndPoint();
            var remotingClient = new SocketRemotingClient(brokerEndpoint, _setting.SocketSetting);
            var adminRemotingClient = new SocketRemotingClient(brokerAdminEndpoint, _setting.SocketSetting);
            var brokerConnection = new BrokerConnection(brokerInfo, remotingClient, adminRemotingClient);

            if (_producer != null && _producer.ResponseHandler != null)
            {
                remotingClient.RegisterResponseHandler((int)BrokerRequestCode.SendMessage, _producer.ResponseHandler);
            }

            brokerConnection.Start();

            return brokerConnection;
        }