Closed acogoluegnes closed 5 years ago
Hello again. I didn't get to work on reproducing the issue in a simple system (yet) but I think I managed to get rid of it in a way that might help point out the problem (if there is one!).
What seems to have worked is this: Instead of trying to produce to rabbitMQ using the sender in the end of the stream, I delegated that work to another stream using a WorkQueueProcessor.
So the example above would look like this:
public void createDisposable(String uuid){
String queueName = "somePrefix" + uuid;
Disposable disposable = sender.declareQueue(QueueSpecification.queue().name(queueName).durable(true))
.flatMap(qOk -> sender.bind(BindingSpecification.binding()
.exchange("someExchange1")
.queue(queueName)
.routingKey("uuid")))
.thenMany(receiver.consumeAutoAck(queueName))
.timeout(Duration.of(60, ChronoUnit.SECONDS))
.filter((delivery)-> delivery.getBody().length != 0)
.flatMap((delivery) -> {
try {
return Flux.just((HashMap<String, String>) objectMapper.readValue(delivery.getBody(), HashMap.class));
} catch (IOException e) {
return Flux.empty();
}
})
.doOnNext(myHashMap -> {
// do some calculations
})
.doOnNext(myHashMap -> producingProcessor.onNext(new OutboundMessage("someExchange2", "", "someRandomString".getBytes())))
.subscribe((next) -> {
log.info("Whatever");
});
runningDisposables.put(uuid, disposable);
}
and the producing to rabbitMQ part happens in another stream looking like this:
public void enableProducerStream(){
producingProcessor.publish()
.autoConnect()
.flatMap(outboundMessage -> sender.send(Mono.just(outboundMessage)).then(Mono.just(outboundMessage)))
.subscribe(outboundMessage -> {
log.info("Produced");
});
}
Now, I'm new to Reactor, so I don't have a solid understanding of it yet but I have a hypothesis:
This might happen to a traffic heavy system in the case where the whole disposable is getting disposed while there are still messages being processed. So maybe some part - the sender I guess - doesn't get the "dispose signal" properly while at the same time it's trying to produce to rabbitMQ so it doesn't close the channel.
@alexreve Thanks for the follow-up and happy to see you managed to make it work properly. I leave this issue open for further investigation later.
No update in about a year, closing.
From: https://gitter.im/reactor/reactor?at=5b314d63479ca266897ee89b
Still need to investigate to kwow whether it's legit or not.