ARTEMIS-918 - use requested routing type when client defined with amqp and address doesnt exist

https://issues.apache.org/jira/browse/ARTEMIS-918
This commit is contained in:
Andy Taylor 2017-01-12 12:07:10 +00:00
parent a5f21fa6af
commit f52cb5c610
2 changed files with 19 additions and 1 deletions

View File

@ -246,7 +246,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
boolean clientDefined = hasCapabilities(TOPIC, source) || hasCapabilities(QUEUE, source); boolean clientDefined = hasCapabilities(TOPIC, source) || hasCapabilities(QUEUE, source);
if (clientDefined) { if (clientDefined) {
multicast = hasCapabilities(TOPIC, source); multicast = hasCapabilities(TOPIC, source);
AddressQueryResult addressQueryResult = sessionSPI.addressQuery(addressToUse.toString(), defaultRoutingType, true); AddressQueryResult addressQueryResult = sessionSPI.addressQuery(addressToUse.toString(), multicast ? RoutingType.MULTICAST : RoutingType.ANYCAST, true);
if (!addressQueryResult.isExists()) { if (!addressQueryResult.isExists()) {
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist(); throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.sourceAddressDoesntExist();
} }

View File

@ -301,6 +301,24 @@ public class ClientDefinedMultiConsumerTest extends AmqpClientTestSupport {
connection.close(); connection.close();
} }
@Test(timeout = 60000)
public void testAddressDoesntExist() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect("myClientId"));
AmqpSession session = connection.createSession();
Source source = createNonSharedSource(TerminusDurability.CONFIGURATION);
Source source1 = createSharedSource(TerminusDurability.CONFIGURATION);
AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub");
try {
session.createMulticastReceiver(source1, "myReceiverID", "mySub|2");
fail("Exception expected");
} catch (Exception e) {
//expected
}
connection.close();
}
private Source createNonSharedSource(TerminusDurability terminusDurability) { private Source createNonSharedSource(TerminusDurability terminusDurability) {
Source source = new Source(); Source source = new Source();
source.setAddress(address.toString()); source.setAddress(address.toString());