diff options
| author | chrislu <chris.lu@gmail.com> | 2025-06-25 17:42:39 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-06-25 17:42:39 -0700 |
| commit | e4fe657bd953d4ce0c823f362584348bfb4903fb (patch) | |
| tree | 0f95eb4221a0ee847c856d61f6595109f972eeb4 /test/mq/simple_demo.go | |
| parent | 31473fbe1053001796388bc0832c93d47f22839e (diff) | |
| download | seaweedfs-origin/adding-message-queue-integration-tests.tar.xz seaweedfs-origin/adding-message-queue-integration-tests.zip | |
perf tests run fineorigin/adding-message-queue-integration-tests
Diffstat (limited to 'test/mq/simple_demo.go')
| -rw-r--r-- | test/mq/simple_demo.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/mq/simple_demo.go b/test/mq/simple_demo.go new file mode 100644 index 000000000..35446e742 --- /dev/null +++ b/test/mq/simple_demo.go @@ -0,0 +1,56 @@ +package main + +import ( + "fmt" + "log" + "time" + + "github.com/seaweedfs/seaweedfs/weed/mq/client/pub_client" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" +) + +func main() { + log.Println("Starting SeaweedMQ logging test...") + + // Create publisher configuration + config := &pub_client.PublisherConfiguration{ + Topic: topic.NewTopic("test", "logging-demo"), + PartitionCount: 3, + Brokers: []string{"127.0.0.1:17777"}, + PublisherName: "logging-test-client", + } + + log.Println("Creating topic publisher...") + publisher, err := pub_client.NewTopicPublisher(config) + if err != nil { + log.Printf("Failed to create publisher: %v", err) + return + } + defer publisher.Shutdown() + + log.Println("Publishing test messages...") + + // Publish some test messages + for i := 0; i < 100; i++ { + key := fmt.Sprintf("key-%d", i) + value := fmt.Sprintf("message-%d-timestamp-%d", i, time.Now().Unix()) + + err := publisher.Publish([]byte(key), []byte(value)) + if err != nil { + log.Printf("Failed to publish message %d: %v", i, err) + } + + // Small delay to create some connection stress + if i%10 == 0 { + time.Sleep(10 * time.Millisecond) + } + } + + log.Println("Finishing publish...") + err = publisher.FinishPublish() + if err != nil { + log.Printf("Failed to finish publish: %v", err) + } + + log.Println("Test completed successfully!") +} |
