Uncatchable exception thrown when connecting with an invalid RMQDestination queue.

124 views
Skip to first unread message

accaaskq...@gmail.com

unread,
Jul 23, 2018, 9:24:46 AM7/23/18
to rabbitmq-users

Hi, I've ran into an issue where when I attempt to set up a message listener on an RMQDestination with an invalid destname the errors can not be caught and instead get thrown I am assuming from SLF4J. The core of the issue is that I need a way to see that an error has occurred on that connection so that I can identify when an invalid queue has been entered. Currently that error will get posted, but to our back end logging, where it will post it multiple times ( due to the persistent nature of AMQP ) and is uncatchable within the code.

I've tried forcing other errors and everything else is caught before it sets up the message listener or after, an invalid destination name seems to be the only cause of making an uncatchable error.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SAMPLE CODE:

I've removed any connection information, but everything but the queue (bolded) is valid.

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;

import com.rabbitmq.client.AlreadyClosedException;
import com.rabbitmq.jms.admin.RMQConnectionFactory;
import com.rabbitmq.jms.admin.RMQDestination;

public class test
{    
    public static void main( String[] args ) throws AlreadyClosedException, Exception
    {
        RMQConnectionFactory connectionFactory = new RMQConnectionFactory();
        connectionFactory.setHost( "dfgdfgdg" );
        connectionFactory.setPort( 5468 );
        connectionFactory.setUseDefaultSslContext( true );
        Connection connection =  connectionFactory.createConnection( "dfgdfgdf", "dfgdgdgfd" );
        connection.start();
        
        RMQDestination queue = new RMQDestination( "queue", null, null, "queue" );
        Session session = connection.createSession( false, Session.CLIENT_ACKNOWLEDGE );
        MessageConsumer messageConsumer = session.createConsumer( queue );
   
        messageConsumer.setMessageListener( new MessageListener()    < This line is when the error gets thrown, but can't be caught.
        {
            @Override
            public void onMessage( Message msg )
            {
                    System.out.println( msg );
                    try
                    {
                        msg.acknowledge();
                    }
                    catch (JMSException e)
                    {
                    }
            }
        } );
    }
}

-------------------------------------------------------------------------------------------------------------------------------------------------------
Error message

Again, i've removed all the identifiable information.


ERROR com.rabbitmq.jms.client.MessageListenerConsumer - basicConsume (consumerTag='') threw exception
java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1369)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicConsume(AutorecoveringChannel.java:540)
at com.rabbitmq.jms.client.RMQMessageConsumer.basicConsume(RMQMessageConsumer.java:275)
at com.rabbitmq.jms.client.MessageListenerConsumer.start(MessageListenerConsumer.java:225)
at com.rabbitmq.jms.client.RMQMessageConsumer.setNewListenerConsumer(RMQMessageConsumer.java:202)
at com.rabbitmq.jms.client.RMQMessageConsumer.setMessageListener(RMQMessageConsumer.java:182)
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to queue '' in vhost '' refused for user '', class-id=60, method-id=20)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1363)
... 9 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - access to queue '' in vhost '' refused for user '', class-id=60, method-id=20)
at com.rabbitmq.client.ShutdownSignalException.<init>(ShutdownSignalException.java:74)
at com.rabbitmq.client.ShutdownSignalException.<init>(ShutdownSignalException.java:59)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:510)
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:346)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:178)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:111)
at com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:670)
at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:48)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:597)
at java.lang.Thread.run(Thread.java:811)

-------------------------------------------------------------------------------------------------------------------------------------------------------

Jars/Versions

Currently using java 8, rabbitmq-jms 1.9.0 and amqp-client-5.2.0


-------------------------------------------------------------------------------------------------------------------------------------------------------
Expected result


What I'd expect is some kind of error to get thrown to my main thread or more control over how the errors are posted. As it is right now, my main thread can't tell when an invalid queue is given and basically fails over endlessly (as it can never connect to an invalid queue). Basically I want my main thread to be able to react to an invalid queue being used.

accaaskq...@gmail.com

unread,
Jul 30, 2018, 10:12:03 AM7/30/18
to rabbitmq-users
Has there been any update on this?

Arnaud Cogoluègnes

unread,
Jul 30, 2018, 10:29:15 AM7/30/18
to rabbitm...@googlegroups.com
We added it to our backlog. According to the specification [1] it'd
make sense to throw an exception at some point. If we go down that
road it will ship in 2.0, as it's a breaking change.

[1] https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#createConsumer-javax.jms.Destination-

On Mon, Jul 30, 2018 at 4:12 PM, <accaaskq...@gmail.com> wrote:
> Has there been any update on this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rabbitmq-user...@googlegroups.com.
> To post to this group, send email to rabbitm...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

accaaskq...@gmail.com

unread,
Jul 30, 2018, 11:20:17 AM7/30/18
to rabbitmq-users
Thanks for looking into this!
Reply all
Reply to author
Forward
0 new messages