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.

30 lines
570 B

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/seaweedfs/weed/mq/client/sub_client"
  5. )
  6. func main() {
  7. subscriber := sub_client.NewTopicSubscriber(
  8. &sub_client.SubscriberConfiguration{
  9. ConsumerGroup: "test",
  10. ConsumerId: "test",
  11. },
  12. "test", "test")
  13. if err := subscriber.Connect("localhost:17777"); err != nil {
  14. fmt.Println(err)
  15. return
  16. }
  17. if err := subscriber.Subscribe(func(key, value []byte) bool {
  18. println(string(key), "=>", string(value))
  19. return true
  20. }, func() {
  21. println("done subscribing")
  22. }); err != nil {
  23. fmt.Println(err)
  24. }
  25. }