gemmellr commented on code in PR #5232:
URL: https://github.com/apache/activemq-artemis/pull/5232#discussion_r1758514272


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AmqpEmbeddedLargeCoreMessageClusterTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.apache.activemq.artemis.tests.integration.amqp.largemessages;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
+import 
org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
+import 
org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class AmqpEmbeddedLargeCoreMessageClusterTest extends ClusterTestBase {
+
+   protected static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   @Test
+   public void testAmqpMessageEmbeddedInLargeCoreMessageAcrossClusterBridge() 
throws Exception {
+      final String address = "address1";
+      for (int i = 0; i < 2; i++) {
+         // start with basic server
+         setupServer(i, true, true);
+
+         // the reproducer does not reproduce without this:
+         // the default is 102400 but this is in the same range as the message 
sizes here
+         getServer(i).getConfiguration().setJournalFileSize(10 * 1024 * 1024);

Review Comment:
   Comment could be a little clearer that its the overall test hardness that 
set 102400 already, the actual default is the same as is being set.



##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/AmqpEmbeddedLargeCoreMessageClusterTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.apache.activemq.artemis.tests.integration.amqp.largemessages;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
+import 
org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
+import 
org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class AmqpEmbeddedLargeCoreMessageClusterTest extends ClusterTestBase {
+
+   protected static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   @Test
+   public void testAmqpMessageEmbeddedInLargeCoreMessageAcrossClusterBridge() 
throws Exception {
+      final String address = "address1";
+      for (int i = 0; i < 2; i++) {
+         // start with basic server
+         setupServer(i, true, true);
+
+         // the reproducer does not reproduce without this:
+         // the default is 102400 but this is in the same range as the message 
sizes here
+         getServer(i).getConfiguration().setJournalFileSize(10 * 1024 * 1024);
+
+         // make sure we can use the AMQP protocol (Proton = AMQP)
+         getServer(i).addProtocolManagerFactory(new 
ProtonProtocolManagerFactory());
+      }
+
+      // make it a proper cluster by connecting the nodes
+      setupClusterConnection(new 
ClusterConnectionConfiguration().setName("broker0"), true, 0, 1);
+      setupClusterConnection(new 
ClusterConnectionConfiguration().setName("broker1"), true, 1, 0);
+
+      // start all nodes
+      startServers(0);
+      startServers(1);
+
+      // create consumer, send messages, then receive them
+      final ConnectionFactory receiverConnectionFactory = new 
JmsConnectionFactory("amqp://localhost:61617");
+      try (Connection receiverConnection = 
receiverConnectionFactory.createConnection();
+           Session receiverSession = receiverConnection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+           MessageConsumer consumer = 
receiverSession.createConsumer(receiverSession.createTopic(address))) {
+
+         final ConnectionFactory senderConnectionFactory = new 
JmsConnectionFactory("amqp://localhost:61616");
+         try (Connection senderConnection = 
senderConnectionFactory.createConnection();
+              Session senderSession = senderConnection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+              MessageProducer producer = 
senderSession.createProducer(senderSession.createTopic(address))) {
+            TextMessage msg = senderSession.createTextMessage();
+            // this is the magic number - small enough to be small, but large 
enough to make the Core message which embeds it large
+            msg.setText("x".repeat(102176));
+            producer.send(msg);
+         }
+
+         receiverConnection.start();
+         assertNotNull(consumer.receive(1000));
+      }

Review Comment:
   This obviously isnt wrong, but would it not be far more readable just to 
have a single try-with-resources block that created both connections up front, 
and then contained a simple sequence of consumer+producer creation and 
send+receive ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to