ARTEMIS-666 Fix AMQP error message on address not found
This commit is contained in:
parent
8a3155c0b4
commit
ab39e70dc9
|
@ -30,6 +30,7 @@ import org.proton.plug.context.AbstractProtonReceiverContext;
|
|||
import org.proton.plug.context.AbstractProtonSessionContext;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPException;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPInternalErrorException;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException;
|
||||
import org.proton.plug.logger.ActiveMQAMQPProtocolMessageBundle;
|
||||
|
||||
import static org.proton.plug.util.DeliveryUtil.readDelivery;
|
||||
|
@ -85,15 +86,18 @@ public class ProtonServerReceiverContext extends AbstractProtonReceiverContext {
|
|||
if (address == null) {
|
||||
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.targetAddressNotSet();
|
||||
}
|
||||
|
||||
try {
|
||||
if (!sessionSPI.queueQuery(address)) {
|
||||
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.errorFindingTemporaryQueue(e.getMessage());
|
||||
catch (ActiveMQAMQPNotFoundException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
flow(maxCreditAllocation, minCreditRefresh);
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.proton.plug.context.AbstractProtonSessionContext;
|
|||
import org.proton.plug.context.ProtonPlugSender;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPException;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPInternalErrorException;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException;
|
||||
import org.proton.plug.logger.ActiveMQAMQPProtocolMessageBundle;
|
||||
|
||||
import static org.proton.plug.AmqpSupport.JMS_SELECTOR_FILTER_IDS;
|
||||
|
@ -223,6 +224,9 @@ public class ProtonServerSenderContext extends AbstractProtonContextSender imple
|
|||
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist();
|
||||
}
|
||||
}
|
||||
catch (ActiveMQAMQPNotFoundException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.proton.plug.exceptions;
|
||||
|
||||
import org.apache.qpid.proton.amqp.transport.AmqpError;
|
||||
|
||||
public class ActiveMQAMQPNotFoundException extends ActiveMQAMQPException {
|
||||
|
||||
public ActiveMQAMQPNotFoundException(String message, Throwable e) {
|
||||
super(AmqpError.NOT_FOUND, message, e);
|
||||
}
|
||||
|
||||
public ActiveMQAMQPNotFoundException(String message) {
|
||||
super(AmqpError.NOT_FOUND, message);
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import org.proton.plug.exceptions.ActiveMQAMQPInvalidFieldException;
|
|||
import org.jboss.logging.annotations.Message;
|
||||
import org.jboss.logging.annotations.MessageBundle;
|
||||
import org.jboss.logging.Messages;
|
||||
import org.proton.plug.exceptions.ActiveMQAMQPNotFoundException;
|
||||
|
||||
/**
|
||||
* Logger Code 11
|
||||
|
@ -44,10 +45,10 @@ public interface ActiveMQAMQPProtocolMessageBundle {
|
|||
ActiveMQAMQPInternalErrorException errorCreatingTemporaryQueue(String message);
|
||||
|
||||
@Message(id = 219002, value = "target address does not exist")
|
||||
ActiveMQAMQPIllegalStateException addressDoesntExist();
|
||||
ActiveMQAMQPNotFoundException addressDoesntExist();
|
||||
|
||||
@Message(id = 219003, value = "error finding temporary queue, {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
ActiveMQAMQPInternalErrorException errorFindingTemporaryQueue(String message);
|
||||
ActiveMQAMQPNotFoundException errorFindingTemporaryQueue(String message);
|
||||
|
||||
@Message(id = 219005, value = "error creating consumer, {0}", format = Message.Format.MESSAGE_FORMAT)
|
||||
ActiveMQAMQPInternalErrorException errorCreatingConsumer(String message);
|
||||
|
@ -62,7 +63,7 @@ public interface ActiveMQAMQPProtocolMessageBundle {
|
|||
ActiveMQAMQPIllegalStateException errorCancellingMessage(String messageID, String message);
|
||||
|
||||
@Message(id = 219010, value = "source address does not exist")
|
||||
ActiveMQAMQPInvalidFieldException sourceAddressDoesntExist();
|
||||
ActiveMQAMQPNotFoundException sourceAddressDoesntExist();
|
||||
|
||||
@Message(id = 219011, value = "source address not set")
|
||||
ActiveMQAMQPInvalidFieldException sourceAddressNotSet();
|
||||
|
|
|
@ -526,6 +526,25 @@ public class ProtonTest extends ActiveMQTestBase {
|
|||
return sentMessages.get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkDetatchErrorIsCorrectWhenQueueDoesNotExists() throws Exception {
|
||||
AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password);
|
||||
AmqpConnection amqpConnection = client.connect();
|
||||
AmqpSession session = amqpConnection.createSession();
|
||||
|
||||
Exception expectedException = null;
|
||||
try {
|
||||
session.createSender("AnAddressThatDoesNotExist");
|
||||
}
|
||||
catch (Exception e) {
|
||||
expectedException = e;
|
||||
}
|
||||
|
||||
assertNotNull(expectedException);
|
||||
assertTrue(expectedException.getMessage().contains("amqp:not-found"));
|
||||
assertTrue(expectedException.getMessage().contains("target address does not exist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplyTo() throws Throwable {
|
||||
|
||||
|
|
Loading…
Reference in New Issue