[rabbitmq-discuss] ReturnListener is not invoked
Matthias Radestock
matthias at rabbitmq.com
Fri Jan 18 06:41:14 GMT 2013
On 17/01/13 23:04, Dmitriy Bannikov wrote:
> I've created a test Java class which tries to publish message into a
> fake queue.
> In Windows this message is failing, and ReturnListener shows it's
> output. In Linux there're not error or fails.
>
> I've just upgraded rabbitmq from 2.8.6 to 3.0.1 on both WIndows and
> Linux machines.
>
> Code is following: [...]
> channel.basicPublish("", "fake_queue_112233", true, true,
> props, "Test String".getBytes());
That call has the 'immediate' flag set. The RabbitMQ server stopped
supporting that in 3.0.0, so the above will result in an
connection-level error.
But since publishing is asynchronous, a client won't see that error
unless it a) stays around long enough for the error to arrive, and b)
either performs some other action on the channel or has an appropriate
error handler (in case of the Java client a ShutdownListener) configured
on the channel. Since the basicPublish is the last thing your program
does, and no handler is installed, the error won't show up. And since
the error that is generated is a connection level error, the connection
will be closed and the program terminates. If you, say, added a
connection.close() at the end of your program, you'd get an error.
Now, if you were just setting mandatory, or running 2.8.6 (where
'immediate' doesn't result in an error) then the return listener should
get invoked. And since a return is a not an error, the connection will
stay alive and the program won't terminate. Indeed all that happens for
me, on Linux, when I try it.
As to why this would behave differently on windows and linux, I suspect
the upgrade of the broker didn't actually happen on the former, so it's
still running 2.8.6.
Regards,
Matthias.
More information about the rabbitmq-discuss
mailing list