[ 
https://issues.apache.org/jira/browse/ARTEMIS-4132?focusedWorklogId=841177&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-841177
 ]

ASF GitHub Bot logged work on ARTEMIS-4132:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Jan/23 16:31
            Start Date: 23/Jan/23 16:31
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on code in PR #4342:
URL: https://github.com/apache/activemq-artemis/pull/4342#discussion_r1084255132


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AutoCreateWithDefaultRoutingTypesTest.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>

Review Comment:
   Incorrect formatting, tags and indent. Presumably copied, original to be 
fixed also. I recently fixed all the ones that were javadoc headers, but guess 
there are more that were already actually comment headers.



##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java:
##########
@@ -1115,8 +1116,15 @@ public Consumer init(ProtonServerSenderContext 
senderContext) throws Exception {
             } else {
                // if not we look up the address
                AddressQueryResult addressQueryResult = null;
+
+               // Set this to the broker configured default for the address 
prior to the lookup so that
+               // an auto create will actually use the configured defaults.  
The actual query result will
+               // contain the true answer on what routing type the address 
actually has though.
+               routingTypeToUse = 
sessionSPI.getDefaultRoutingType(addressToUse);
+               routingTypeToUse = routingTypeToUse == null ? 
ActiveMQDefaultConfiguration.getDefaultRoutingType() : routingTypeToUse;

Review Comment:
   I think this one might be more obvious with a simple if doing a potential 
update, rather than using the ternary and setting itself to itself in many/most 
cases.



##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AutoCreateWithDefaultRoutingTypesTest.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.apache.activemq.artemis.tests.integration.amqp;
+
+import static 
org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_CAPABILITY;
+import static 
org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TOPIC_CAPABILITY;
+
+import java.lang.invoke.MethodHandles;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.AddressQueryResult;
+import org.apache.activemq.artemis.core.server.JournalType;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.transport.amqp.client.AmqpClient;
+import org.apache.activemq.transport.amqp.client.AmqpConnection;
+import org.apache.activemq.transport.amqp.client.AmqpReceiver;
+import org.apache.activemq.transport.amqp.client.AmqpSender;
+import org.apache.activemq.transport.amqp.client.AmqpSession;
+import org.apache.qpid.proton.amqp.messaging.Source;
+import org.apache.qpid.proton.amqp.messaging.Target;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(Parameterized.class)
+public class AutoCreateWithDefaultRoutingTypesTest extends 
JMSClientTestSupport {
+
+   private static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   @Parameterized.Parameters(name = "routingType={0}")
+   public static Collection<Object[]> parameters() {
+      return Arrays.asList(new Object[][] {
+         {RoutingType.ANYCAST}, {RoutingType.MULTICAST}
+      });
+   }
+
+   @Parameterized.Parameter(0)
+   public RoutingType routingType;
+
+   @Override
+   protected String getConfiguredProtocols() {
+      return "AMQP";
+   }
+
+   @Override
+   protected void createAddressAndQueues(ActiveMQServer server) throws 
Exception {
+      // Don't create anything by default since we are testing auto create
+   }
+
+   @Override
+   protected void configureAddressPolicy(ActiveMQServer server) {
+      Configuration serverConfig = server.getConfiguration();
+      serverConfig.setJournalType(JournalType.NIO);
+      Map<String, AddressSettings> map = serverConfig.getAddressSettings();
+      if (map.size() == 0) {
+         AddressSettings as = new AddressSettings();
+         map.put("#", as);
+      }
+      Map.Entry<String, AddressSettings> entry = 
map.entrySet().iterator().next();
+      AddressSettings settings = entry.getValue();
+      settings.setAutoCreateQueues(true);
+      settings.setDefaultAddressRoutingType(routingType);
+      settings.setDefaultQueueRoutingType(routingType);
+      logger.info("server cofg, isauto? {}", 
entry.getValue().isAutoCreateQueues());
+      logger.info("server cofg, default queue routing type? {}", 
entry.getValue().getDefaultQueueRoutingType());
+      logger.info("server cofg, default address routing type? {}", 
entry.getValue().getDefaultAddressRoutingType());

Review Comment:
   cofg = config?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 841177)
    Time Spent: 20m  (was: 10m)

> broker uses anycast for amqp destination which is configured as multicast
> -------------------------------------------------------------------------
>
>                 Key: ARTEMIS-4132
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4132
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 2.27.1
>            Reporter: Erwin Dondorp
>            Priority: Major
>         Attachments: Dockerfile.recv, Dockerfile.send, recv.py, send.py
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> using:
> * broker configured with default-address-routing-type=MULTICAST (and 
> default-queue-routing-type=MULTICAST)
> * clients built with python-qpid-proton, but we have seen the same effect 
> with other amqp clients
> When a client is publishing to a new address, the address is created with 
> routing type MULTICAST. this is ok.
> When a client is subscribing to a new address, the address is created with 
> routing type ANYCAST, which is unexpected.
> To repeat:
> * create plain broker using {{bin/artemis create --allow-anonymous --user 
> admin --password admin broker1}}
> * (optional) adjust {{broker1/etc/bootstrap.xml}} and/or adjust 
> {{broker1/etc/jolokia-access.xml}} when the broker console can otherwise not 
> be used/reached.
> * update {{broker.xml}}: add these 2 lines to the {{address-settings}} for 
> '{{#}}'
> {{<default-queue-routing-type>MULTICAST</default-queue-routing-type>}}
> {{<default-address-routing-type>MULTICAST</default-address-routing-type>}}
> * start broker with {{broker1/bin/artemis run}}
> * adjust the broker address in the 2 python files
> * use supplied docker files to build and run a sender and/or a receiver
> scenario 1:
> run only the broker and the sender
> see address '{{demoaddress}}' appear as multicast address
> any messages will disappear as expected because there is no consumer
> scenario 2:
> run only the broker and the receiver
> see address '{{demoaddress}}' appear as anycast (unexpected) address
> a queue with the same name is created under it (consistent)
> remove the address '{{demoaddress}}' between runs because the effect only 
> appears for new addresses
> see the attached files
> [~jbertram]: as discussed in the mailing list



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to