Comments (6)
Do you have more details? Do you mean that this flow of reconnecting is not executing properly: https://github.com/ThreeDotsLabs/watermill-amqp/blob/master/pkg/amqp/subscriber.go#L70 ?
from watermill.
I simulated the rabbmitmq outage
Stopped rabbmitmq
But I don't know how to use your package to capture disconnected yics
I want to catch the exception
Reestablishing channels
from watermill.
How should I add
Listen for rabbmitmq disconnect event
from watermill.
I checked all the documents
There's still no way to write it down
Sorry to bother you.
from watermill.
Hi, I have the same problem.
I think that when the connection is lost and reconnection is done the message channel stops receiving them.
For example, in a loop like the one in the example, messages stop being received.
func process(messages <-chan *message.Message) {
for msg := range messages {
log.Printf("received message: %s, payload: %s", msg.UUID, string(msg.Payload))
// we need to Acknowledge that we received and processed the message,
// otherwise, it will be resent over and over again.
msg.Ack()
}
}
I haven't had much time to look at the reconnect implementation but it's probably something related to the code you said (https://github.com/ThreeDotsLabs/watermill-amqp/blob/master/pkg/amqp/subscriber.go#L70)
Any ideas?
Thanks :D
from watermill.
Hello @sdeancos @duolabmeng6 I checked locally and with tests (https://github.com/ThreeDotsLabs/watermill-amqp/blob/master/pkg/amqp/pubsub_reconnect_test.go) and it seems that reconnect is working for me properly. Can you provide a bit more details to reproduce it? Thanks!
This is the code that I'm using
package main
import (
"context"
"fmt"
"time"
"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-amqp/pkg/amqp"
"github.com/ThreeDotsLabs/watermill/message"
)
func createPubSub() (message.Publisher, message.Subscriber) {
publisher, err := amqp.NewPublisher(
amqp.NewDurablePubSubConfig(
"amqp://guest:guest@localhost:5672",
nil,
),
watermill.NewStdLogger(true, true),
)
if err != nil {
panic(err)
}
subscriber, err := amqp.NewSubscriber(
amqp.NewDurablePubSubConfig(
"amqp://guest:guest@localhost:5672",
amqp.GenerateQueueNameTopicNameWithSuffix("test"),
),
watermill.NewStdLogger(true, true),
)
if err != nil {
panic(err)
}
return publisher, subscriber
}
func main() {
pub, sub := createPubSub()
go func() {
for {
pub.Publish("foo", message.NewMessage(time.Now().String(), nil))
time.Sleep(time.Second)
}
}()
msgs, err := sub.Subscribe(context.Background(), "foo")
if err != nil {
panic(err)
}
for msg := range msgs {
fmt.Println(msg.UUID)
msg.Ack()
}
}
and docker-compose:
version: '3'
services:
rabbitmq:
image: rabbitmq:3.7-management
restart: unless-stopped
ports:
- 5672:5672
I'm running the Go code and I'm restarting docker to force re-connect.
from watermill.
Related Issues (20)
- Log with fields on error in router HOT 3
- s
- MaxOutstandingMessages doesn't seem to be working
- follow-up handler will be broke while before msg handler error, what is the best practice for this situation?
- `msg.Nack` causes infinite loop with gochannel pubsub HOT 4
- Publish message processing delay in metrics Middleware?
- How to subscribe to all gochannel ? HOT 2
- Any plans to add support of RabbitMQ Streaming?
- Generated topic names for PubSub tests does not conform with Azure guidelines
- How to delete message after ack? HOT 1
- Context not being propagated through command bus HOT 2
- Is it possible to get google pubsub server generated unique message-id? HOT 3
- Data race on Publish for Google pubsub
- SQLite driver HOT 4
- Log custom fields inside message router
- Invalid publisher name in metrics
- Resume after shutdown always fetch last interrupted message again
- How to process a batch of received messages instead of a single piece?
- Can you output the message metadata to the logs?
- Only post messages after subscribing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watermill.