[rabbitmq-discuss] Improving our documentation

Rob Harrop rob at rabbitmq.com
Tue Nov 23 11:16:55 GMT 2010


On Tue, 23 Nov 2010 11:29:59 +0100, jiri at krutil.com wrote:
>>> Btw, I guess the finally block in Recv won't get executed unless an
>>> exception is thrown -- that means no clean shutdown is possible. But I
>>> guess that's OK for a hello-world app.
>>
>> The finally block _always_ gets executed, whether the is an exception
or
>> not, so you get both clean shutdown, and shutdown in the case of an
>> exception.
> 
> The finally block does not get executed if you stop the JVM.
> 
> The endless loop in Recv.main() can only end in two ways: exception or  
> JVM shutdown. I don't see a way how to perform a clean shutdown of the  
> receiver.
> 
> If the user stops the receiver by killing the Java process, the  
> connection will stay open on the broker and will have to time out. In  
> my opinion that's a reasource leak, which should not appear in a  
> tutorial.
> 
> Jiri

Ah, I didn't realise you were talking about abrupt termination :)

We could register a shutdown hook to perform clean up on exit, but that
feels like overkill for such a simple example. I can't think of another way
to guarantee that cleanup happens. Even without the infinite loop a user
can still Ctrl-C.

What do you think would be best here?

I'm very tentatively toying with the idea of working up a patch for the
client itself that will register a shutdown hook and maintain a set of weak
refs to connections for clean up on termination. What do you think about
this?

Rob


More information about the rabbitmq-discuss mailing list