Comments (4)
then i try other way, the code below, the process block forever:
conn, err := rabbitmq.NewConn("amqp://xxx:[email protected]:5672/")
if err != nil {
return err
}
args := rabbitmq.Table{
"x-delayed-type": "direct",
}
pub, err := rabbitmq.NewPublisher(conn,
rabbitmq.WithPublisherOptionsExchangeKind("x-delayed-message"),
rabbitmq.WithPublisherOptionsExchangeDurable,
rabbitmq.WithPublisherOptionsExchangeName("panda.test.delay"),
rabbitmq.WithPublisherOptionsExchangeArgs(args),
)
defer pub.Close()
if err != nil {
return err
}
confirmRes := make(chan bool, 1)
pub.NotifyPublish(func(p rabbitmq.Confirmation) {
confirmRes <- p.Ack
close(confirmRes)
})
err = pub.PublishWithContext(context.Background(), []byte(`{"test":"a"}`), []string{"delay.queue"},
rabbitmq.WithPublishOptionsContentType("application/json"),
rabbitmq.WithPublishOptionsPersistentDelivery,
rabbitmq.WithPublishOptionsExchange("panda.test.delay"),
rabbitmq.WithPublishOptionsTimestamp(time.Now()),
)
if err != nil {
return err
}
for k := range confirmRes {
if !k {
return errors.New("server confirm fail")
}
}
i read the code, find pub.NotifyPublish can't ensure execute before pub.PublishWithContext, so block forever ?
from go-rabbitmq.
I have the same problem as described in the description of this issue. When I step through the code, I get to "github.com/rabbitmq/amqp091-go", channel.go:1439
which has ch.confirming
equal to false
which is why the DeferredConfirmation
we get is false.
It looks like the code on publish.go:334
never runs, and therefore never sets the channel into Confirm Mode. @michale-developer did you ever solve this problem?
@wagslane please could you assist?
from go-rabbitmq.
I have the same problem as described in the description of this issue. When I step through the code, I get to "github.com/rabbitmq/amqp091-go",
channel.go:1439
which hasch.confirming
equal tofalse
which is why theDeferredConfirmation
we get is false.It looks like the code on
publish.go:334
never runs, and therefore never sets the channel into Confirm Mode. @michale-developer did you ever solve this problem?@wagslane please could you assist?
I found a workaround. This library ONLY sets the channel into Confirm Mode under two conditions:
- If it disconnects and needs to be reconnected (
publish.go:117
) - If a NotifyPublish handler is used. (
publish.go:308
)
(because those are the only two timesstartPublishHandler
is called which invokespublisher.chanManager.ConfirmSafe(false)
)
So, a workaround is to create a blank NotifyPublish handler even if you don't need one. e.g:
publisher.NotifyPublish(func(p rabbitmq.Confirmation) {
// DO NOTHING! - THIS IS JUST HERE TO MAKE SURE THE CHANNEL IS PUT INTO CONFIRM MODE
})
from go-rabbitmq.
Fixed in the latest! You should just need to NotifyPublish
OR set the publisher to confirm mode
from go-rabbitmq.
Related Issues (20)
- get message in a variable like github.com/streadway/amqp HOT 2
- error on ack HOT 1
- Retry Publish Option HOT 5
- Direct reply-to HOT 2
- rabbitmq-manager no consumers HOT 2
- only reconnecting some consumers HOT 1
- Shutdown after a fixed number of reconnection attempts HOT 2
- Support for Dead Letter Exchange HOT 1
- Cluster support HOT 1
- Declare queue without consuming messages HOT 2
- My business requires batch processing of messages. Currently, the Consumer can only provide one callback at a time. Can I open up chan (msgs)? I want to handle message callbacks myself HOT 1
- received 'direct' but current is 'topic'" HOT 1
- A queue can accept multiple bindings from multiple exchanges HOT 1
- Support for RabbitMQ Clusters HOT 3
- memory leak HOT 20
- how to gracefully shutdown mq consumers?
- Docs specify `WithPublisherOptionsExchangeDeclare` *stops* this library from declaring the exchanges existance
- Asynchronous reconnection HOT 3
- NotifyPublish ReconnectCount - how is it intended to be used? HOT 2
- reconnection bug HOT 3
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 go-rabbitmq.