You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
501 B

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/seaweedfs/weed/mq/client/pub_client"
  5. )
  6. func main() {
  7. publisher := pub_client.NewTopicPublisher(
  8. "test", "test")
  9. if err := publisher.Connect("localhost:17777"); err != nil {
  10. fmt.Println(err)
  11. return
  12. }
  13. for i := 0; i < 10; i++ {
  14. if dataErr := publisher.Publish(
  15. []byte(fmt.Sprintf("key-%d", i)),
  16. []byte(fmt.Sprintf("value-%d", i)),
  17. ); dataErr != nil {
  18. fmt.Println(dataErr)
  19. return
  20. }
  21. }
  22. fmt.Println("done publishing")
  23. }