Comments (6)
I'll look into this this evening.
from op-rabbit.
-
That solution only works when publishing messages directly to the queue. I fear that having op-rabbit handle such a thing would explode the complexity. I think providing a way to specify that requirement is a better idea.
-
The ack is coming from RabbitMQ itself. See https://www.rabbitmq.com/confirms.html
We can publish the message in mandatory mode, but unfortunately, that causes the message to be routed back to us without the delivery tag, and unless if set the delivery tag in a custom header for every outbound message, I don't see any way to NACK a message that did not get delivered. It does highlight a bigger issue, however. Perhaps the best way to do it would be to have the application allocate a confirmedPublisher per sink, have it publish in mandatory mode, and then have the whole sink fail if a message is unrouteable.
from op-rabbit.
I've been thinking about this... I just switched the publisher strategy from a function that receives a channel, payload, etc. and returns unit. Since a publisher strategy can be bound to a specific queue, you could have it verify the existence of the queue to which it's publishing, and then fail if it doesn't exist.
class VerifyingQueuePublisher(queue: String) extends MessagePublisher {
private var queueVerified = false
def apply(c: Channel, data: Array[Byte], properties: BasicProperties): Unit = {
if (!queueVerified) {
c.queueDeclarePassive(queueName)
queueVerified = true
}
c.basicPublish("", queue, properties, data)
}
}
// returns failed Future if target queue does not exist:
rabbitControl ? ConfirmedMessage(VerifyingQueuePublisher(queueName), data)
What do you think of this? Would this solve your problem?
from op-rabbit.
Yeah, that looks pretty good. I was going to suggest adding another function to MessagePublisher that gets called when the stream is materialized, but this might be better as it keeps the interface simple. The only drawback I can see, is that in order to verify the queue exists, it means making the publisher mutable.
About the confirmations, I have no idea how I didn't notice it before, but that's really bad. What's the point of sending an ack if the message wasn't persisted (or, at least, not where the sender intended it to be)?
Anyway, I'm not so sure about the mandatory mode, it seems like a lot of overhead without necessarily solving the problem.
from op-rabbit.
Okay, great. Thanks for the feedback. I'll work towards making this a reality (what's lacking is proper error handling in the publisher strategy, and channeling that exception back from the ConfirmedPublisher) And... it's not mutable... it's "memoized / lazy"! :D
I'm also going to work on simplifying the definition of implementing custom consumer patterns, providing "escape" hatches where you can leave the opinionated / safety of op-rabbit
when needed.
from op-rabbit.
Supported; 6b743ba
from op-rabbit.
Related Issues (20)
- Subscription `closed` future is never completed when channel creation fails HOT 3
- Exemplify how to provide config at runtime HOT 1
- Messages getting stuck in retry queue even though max retry count is not met HOT 1
- Support for consuming of messages different types HOT 3
- Handling 403 ACCESS_REFUSED for exclusive consumers
- Improve circe encoder HOT 2
- Suggestion: change Message and all composed classes from class to case class
- read from one RabbitMQ and publish to another HOT 2
- publish scala 2.13 release HOT 8
- upgrade to Play JSON 2.7.4
- I can read from this RabbitMQ, but not using op-rabbit HOT 4
- DeadLetter not recognised
- Direct queue properties
- Release a new version HOT 2
- Is asynchronous nack thread blocking? HOT 4
- Delayed message addon
- Add x-queue-mode to predefined queue props
- Where is op-rabbit-upickle published? HOT 1
- Can someone help provide how to do proper shutdown in demo? HOT 3
- Apache Pekko support HOT 2
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 op-rabbit.