There are a few issues here:
- exchange.upgradeChannel(string) is called after the response channel has been flushed, so it can't set the response code or modify headers as the response is commited
- resumeWrites() is not being called if the flush does not succeed
- ChannelListeners.invokeChannelListener(exchange.getConnection().getChannel(), listener); is not being called if the flush does suceed