[
https://issues.apache.org/jira/browse/ARTEMIS-4787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Justin Bertram updated ARTEMIS-4787:
------------------------------------
Description:
As a preface, I am aware that creating both anycast and multicast queues on the
same address is an anti-pattern and not recommended. However, this is causing
difficulties migrating over legacy clients from using Classic to Artemis.
If one creates a JMS topic on an address, and then tries to create a JMS queue,
it fails to create. However, if the order is flipped (creating a queue, then a
topic), there is no exception.
It seems like the issue is in this area of {{ServerSessionImpl}}:
{code:java}
Bindings bindings =
server.getPostOffice().lookupBindingsForAddress(unPrefixedAddress);
if (bindings != null && bindings.hasLocalBinding() && !queueConfig.isFqqn()) {
// The address has another queue with a different name, which is fine. Just
ignore it.
result = AutoCreateResult.EXISTED;{code}
Please see test below to reproduce, which throws the exception immediately as
seen in production.
{code:java}
package org.apache.activemq.artemis.tests.integration;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
import org.junit.Test;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;
import java.util.HashMap;
public class QueueTopicSameNameTest extends ActiveMQTestBase {
protected ActiveMQServer server;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = createServer(true, createDefaultNettyConfig());
server.start();
}
@Test
public void testTopicThenQueueCreate() throws Exception {
String myAddr = "TEST";
ConnectionFactory cf = new
org.apache.activemq.ActiveMQConnectionFactory("failover:(tcp://localhost:61616)");
Connection c = cf.createConnection();
Session s = c.createSession();
Topic t = s.createTopic(myAddr);
MessageConsumer consumer = s.createConsumer(t);
Queue q = s.createQueue(myAddr);
MessageConsumer otherConsumer = s.createConsumer(q);
c.close();
}
}{code}
was:
As a preface, I am aware that creating both anycast and multicast queues on the
same address is an anti-pattern and not recommended. However, this is causing
difficulties migrating over legacy clients from using Classic to Artemis.
If one creates a JMS topic on an address, and then tries to create a JMS queue,
it fails to create. However, if the order is flipped (creating a queue, then a
topic), there is no exception.
It seems like the issue is in this area of {{ServerSessionImpl}}:
{code:java}
Bindings bindings =
server.getPostOffice().lookupBindingsForAddress(unPrefixedAddress);
if (bindings != null && bindings.hasLocalBinding() && !queueConfig.isFqqn()) {
// The address has another queue with a different name, which is fine. Just
ignore it.
result = AutoCreateResult.EXISTED;{code}
Please see test below to reproduce, which throws the exception immediately as
seen in production.
{code:java}
package org.apache.activemq.artemis.tests.integration;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
import org.junit.Test;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;
import java.util.HashMap;
public class QueueTopicSameNameTest extends ActiveMQTestBase {
protected ActiveMQServer server;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = createServer(true, createDefaultNettyConfig());
server.start();
}
@Test
public void testTopicThenQueueCreate() throws Exception {
String myAddr = "TEST";
ConnectionFactory cf = new
org.apache.activemq.ActiveMQConnectionFactory("failover:(tcp://localhost:61616)");
Connection c = cf.createConnection();
Session s = c.createSession();
Topic t = s.createTopic(myAddr);
MessageConsumer consumer = s.createConsumer(t);
Queue q = s.createQueue(myAddr);
MessageConsumer otherConsumer = s.createConsumer(q);
c.close();
}
}{code}
> Anycast queue does not auto-create if already multicast queue on same address
> -----------------------------------------------------------------------------
>
> Key: ARTEMIS-4787
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4787
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker
> Reporter: Josh Byster
> Priority: Major
>
> As a preface, I am aware that creating both anycast and multicast queues on
> the same address is an anti-pattern and not recommended. However, this is
> causing difficulties migrating over legacy clients from using Classic to
> Artemis.
> If one creates a JMS topic on an address, and then tries to create a JMS
> queue, it fails to create. However, if the order is flipped (creating a
> queue, then a topic), there is no exception.
> It seems like the issue is in this area of {{ServerSessionImpl}}:
> {code:java}
> Bindings bindings =
> server.getPostOffice().lookupBindingsForAddress(unPrefixedAddress);
> if (bindings != null && bindings.hasLocalBinding() && !queueConfig.isFqqn()) {
> // The address has another queue with a different name, which is fine.
> Just ignore it.
> result = AutoCreateResult.EXISTED;{code}
> Please see test below to reproduce, which throws the exception immediately as
> seen in production.
> {code:java}
> package org.apache.activemq.artemis.tests.integration;
> import org.apache.activemq.artemis.api.core.client.ClientSession;
> import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
> import org.apache.activemq.artemis.api.core.client.ServerLocator;
> import org.apache.activemq.artemis.core.server.ActiveMQServer;
> import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
> import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
> import org.junit.Before;
> import org.junit.Test;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.MessageConsumer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.Topic;
> import java.util.HashMap;
> public class QueueTopicSameNameTest extends ActiveMQTestBase {
> protected ActiveMQServer server;
> @Override
> @Before
> public void setUp() throws Exception {
> super.setUp();
> server = createServer(true, createDefaultNettyConfig());
> server.start();
> }
> @Test
> public void testTopicThenQueueCreate() throws Exception {
> String myAddr = "TEST";
> ConnectionFactory cf = new
> org.apache.activemq.ActiveMQConnectionFactory("failover:(tcp://localhost:61616)");
> Connection c = cf.createConnection();
> Session s = c.createSession();
> Topic t = s.createTopic(myAddr);
> MessageConsumer consumer = s.createConsumer(t);
> Queue q = s.createQueue(myAddr);
> MessageConsumer otherConsumer = s.createConsumer(q);
> c.close();
> }
> }{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact