We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fail to publish mq, with the "service not found". can anyone help ? thank you.
package main
import ( "context" "fmt" mq "github.com/go-micro/plugins/v4/broker/rabbitmq" "github.com/go-micro/plugins/v4/registry/etcd" "log" "time"
"go-micro.dev/v4" "go-micro.dev/v4/broker" registry "go-micro.dev/v4/registry"
)
var ( topic = "go.micro.topic.foo" )
type Request struct { Name string json:"name" }
json:"name"
type Response struct { Message string json:"message" }
json:"message"
type Helloworld struct{}
func (h *Helloworld) Greeting(ctx context.Context, req *Request, rsp *Response) error { rsp.Message = "Hello " + req.Name fmt.Println("!!!!!!!!!!!!!")
msg := &broker.Message{ Header: map[string]string{ "id": fmt.Sprintf("%d", 1), }, Body: []byte(fmt.Sprintf("%d: %s", 1, time.Now().String())), } if err := broker.Publish(topic, msg); err != nil { log.Printf("[pub] failed: %v", err) } else { fmt.Println("[pub] pubbed message:", string(msg.Body)) } fmt.Println("!!!!!!!!!!!!!") return nil
}
func main() {
edcdRegistry := etcd.NewRegistry(registry.Addrs("192.168.2.89:2379")) mqbroker := mq.NewBroker(broker.Addrs("amqp://guest:[email protected]:5672/")) service := micro.NewService( micro.Name("helloworld"), micro.Handle(new(Helloworld)), micro.Address(":8080"), micro.Registry(edcdRegistry), ) service.Init(micro.Broker(mqbroker)) service.Run()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
fail to publish mq, with the "service not found".
can anyone help ? thank you.
package main
import (
"context"
"fmt"
mq "github.com/go-micro/plugins/v4/broker/rabbitmq"
"github.com/go-micro/plugins/v4/registry/etcd"
"log"
"time"
)
var (
topic = "go.micro.topic.foo"
)
type Request struct {
Name string
json:"name"
}
type Response struct {
Message string
json:"message"
}
type Helloworld struct{}
func (h *Helloworld) Greeting(ctx context.Context, req *Request, rsp *Response) error {
rsp.Message = "Hello " + req.Name
fmt.Println("!!!!!!!!!!!!!")
}
func main() {
}
The text was updated successfully, but these errors were encountered: