You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a simple xpub/xsub server to support my system, but it appears to be running at a high CPU load even when there is no traffic going on. I am building with go 1.14.4, and I'm running on a smaller gumstix processor, but I wouldn't expect the server to take 45% of the CPU with no traffic at all.
// this is the main file for the XPUB/XSUB implementation for
// ZeroMQ. This is the main message broker that handles routing
// publications and subscriptions and the corresponding messages
func main() {
fmt.Printf("Starting up XPUBSUB for ports pub:%d and sub:%d\n", PUBLICATION_PORT, SUBSCRIPTION_PORT)
// all of the work here is done via the proxy class
proxy := zmq.NewProxy()
var err error
// set up the subscription port
connection := fmt.Sprintf(">tcp://localhost:%d", SUBSCRIPTION_PORT)
err = proxy.SetFrontend(zmq.XSub, connection)
if err != nil {
fmt.Println("Cannot set front-end:", err)
}
// set up the publication port
connection = fmt.Sprintf("@tcp://*:%d", PUBLICATION_PORT)
err = proxy.SetBackend(zmq.XPub, connection)
if err != nil {
fmt.Println("Cannot set back-end:", err)
}
// the proxy runs in a separate thread handling all of the
// work. Our main thread just needs to hang around to keep
// the application alive.
for {
time.Sleep(1)
}
}
The text was updated successfully, but these errors were encountered:
I have created a simple xpub/xsub server to support my system, but it appears to be running at a high CPU load even when there is no traffic going on. I am building with go 1.14.4, and I'm running on a smaller gumstix processor, but I wouldn't expect the server to take 45% of the CPU with no traffic at all.
// this is the main file for the XPUB/XSUB implementation for
// ZeroMQ. This is the main message broker that handles routing
// publications and subscriptions and the corresponding messages
package main
import (
"fmt"
"time"
)
const (
PUBLICATION_PORT = 10000
SUBSCRIPTION_PORT = 10001
)
func main() {
fmt.Printf("Starting up XPUBSUB for ports pub:%d and sub:%d\n", PUBLICATION_PORT, SUBSCRIPTION_PORT)
// all of the work here is done via the proxy class
proxy := zmq.NewProxy()
var err error
// set up the subscription port
connection := fmt.Sprintf(">tcp://localhost:%d", SUBSCRIPTION_PORT)
err = proxy.SetFrontend(zmq.XSub, connection)
if err != nil {
fmt.Println("Cannot set front-end:", err)
}
// set up the publication port
connection = fmt.Sprintf("@tcp://*:%d", PUBLICATION_PORT)
err = proxy.SetBackend(zmq.XPub, connection)
if err != nil {
fmt.Println("Cannot set back-end:", err)
}
// the proxy runs in a separate thread handling all of the
// work. Our main thread just needs to hang around to keep
// the application alive.
for {
time.Sleep(1)
}
}
The text was updated successfully, but these errors were encountered: