From 7e6497cc1cc272343eaa9940a34f753ca120a9e6 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 15 Jan 2024 20:42:46 -0800 Subject: [PATCH] adjust publisher subscriber --- weed/mq/client/cmd/weed_pub/publisher.go | 7 ++++--- weed/mq/client/cmd/weed_sub/subscriber.go | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/weed/mq/client/cmd/weed_pub/publisher.go b/weed/mq/client/cmd/weed_pub/publisher.go index 01ac48d13..59469e66b 100644 --- a/weed/mq/client/cmd/weed_pub/publisher.go +++ b/weed/mq/client/cmd/weed_pub/publisher.go @@ -12,7 +12,8 @@ import ( var ( messageCount = flag.Int("n", 1000, "message count") - concurrency = flag.Int("c", 4, "concurrency count") + concurrency = flag.Int("c", 4, "concurrent publishers") + partitionCount = flag.Int("p", 6, "partition count") namespace = flag.String("ns", "test", "namespace") topic = flag.String("topic", "test", "topic") @@ -38,8 +39,8 @@ func doPublish(publisher *pub_client.TopicPublisher, id int) { func main() { flag.Parse() config := &pub_client.PublisherConfiguration{ - CreateTopic: true, - CreateTopicPartitionCount: 1, + CreateTopic: true, + CreateTopicPartitionCount: int32(*partitionCount), } publisher := pub_client.NewTopicPublisher(*namespace, *topic, config) brokers := strings.Split(*seedBrokers, ",") diff --git a/weed/mq/client/cmd/weed_sub/subscriber.go b/weed/mq/client/cmd/weed_sub/subscriber.go index 413768a98..a175c948a 100644 --- a/weed/mq/client/cmd/weed_sub/subscriber.go +++ b/weed/mq/client/cmd/weed_sub/subscriber.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/mq/client/sub_client" + "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "strings" @@ -15,15 +16,17 @@ var ( namespace = flag.String("ns", "test", "namespace") topic = flag.String("topic", "test", "topic") seedBrokers = flag.String("brokers", "localhost:17777", "seed brokers") + + clientId = flag.Uint("client_id", uint(util.RandomInt32()), "client id") ) func main() { flag.Parse() subscriberConfig := &sub_client.SubscriberConfiguration{ - ClientId: "testSubscriber", + ClientId: fmt.Sprintf("client-%d", *clientId), ConsumerGroup: "test", - ConsumerGroupInstanceId: "test", + ConsumerGroupInstanceId: fmt.Sprintf("client-%d", *clientId), GrpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()), } @@ -35,7 +38,7 @@ func main() { } processorConfig := sub_client.ProcessorConfiguration{ - ConcurrentPartitionLimit: 6, + ConcurrentPartitionLimit: 3, } brokers := strings.Split(*seedBrokers, ",")