Hello!
@pebbe, first of all, thank you for the perfect instrument!
I made pub-sub proxy.
However, Router in Golang with zmq4-lib loses in message processing of the same on Python implementation.
Can you tell me what I'm doing wrong or it may be due to the peculiarities of the language? On Python i used the pyzmq library.
Version of libzmq 4.3.5
I used a ticker for stopping program after 5 second in SUB.
The code of SUBs, Routers (Python, Golang) and PUBs below:
PUB
package main
import (
"encoding/json"
zmq "github.com/pebbe/zmq4"
"log"
"os"
"os/signal"
"sync"
"time"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
func main() {
var err error
var i int64
var c = make(chan os.Signal, 1)
var wg sync.WaitGroup
ctx, _ := zmq.NewContext()
publisher, _ := ctx.NewSocket(zmq.PUB)
publisher.Bind("tcp://*:6000")
defer publisher.Close()
signal.Notify(c, os.Interrupt)
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-c:
log.Println("Stopped")
return
case <-time.After(time.Nanosecond * 0):
if i%2 == 0 {
x := new(Person)
x.Name = "Test1"
x.Age = 28
data, _ := json.Marshal(x)
_, err = publisher.SendMessage("front1", data)
if err != nil {
return
}
clear(data)
x = nil
} else {
x := new(Person)
x.Name = "Test2"
x.Age = 24
data, _ := json.Marshal(x)
_, err = publisher.SendMessage("front2", data)
if err != nil {
return
}
clear(data)
x = nil
}
i++
}
}
}()
wg.Wait()
log.Println("Ended")
}
Hello! @pebbe, first of all, thank you for the perfect instrument! I made pub-sub proxy. However, Router in Golang with zmq4-lib loses in message processing of the same on Python implementation. Can you tell me what I'm doing wrong or it may be due to the peculiarities of the language? On Python i used the pyzmq library.
Version of libzmq 4.3.5
I used a ticker for stopping program after 5 second in SUB.
The code of SUBs, Routers (Python, Golang) and PUBs below:
PUB
Router in Go:
Router in Python:
SUB: