You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Logan Barnett (JIRA)" <ji...@apache.org> on 2014/01/23 20:38:37 UTC

[jira] [Updated] (QPID-5510) Creating a durable subscription when the topic address has '{create: never}' creates the subscription anyways.

     [ https://issues.apache.org/jira/browse/QPID-5510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Logan Barnett updated QPID-5510:
--------------------------------

    Description: 
I've been subscribing to a non-existing topic, and the topic subscription succeeds. Here's the address string in the properties file I'm using:
{noformat}
destination.dontCreateTopicExchange = amq.topic / test-create-failure; { create: never, assert: always, node: { durable: True, type: topic }, mode: consume } {noformat}

Here's the junit test:
{code:java}
    @Test
    public void testSubscriptionCannotBeCreatedWithCreateNever() throws Exception {
        Context context = null;
        Session session = null;
        Connection connection = null;
        MessageConsumer messageConsumer = null;
        
        try {
            Properties properties = new Properties();
            properties.load(this.getClass().getResourceAsStream("/hello.properties"));
            context = new InitialContext(properties);

            ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("qpidConnectionfactory");
            connection = connectionFactory.createConnection();
            connection.start();

            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Destination destination = (Destination)context.lookup("dontCreateTopicExchange");

            Topic topic = (Topic)destination;
            System.out.println("Subscribing to topic (" + topic.toString() + ") " + topic.getTopicName());

            try {
                messageConsumer = session.createConsumer((Topic)destination);
                // should not have gotten this far
                Assert.fail("Expected Session.createConsumer() to fail, but it succeeded.");
            }
            catch(JMSException e) { }

        }
        finally {
            if(messageConsumer != null) messageConsumer.close();
            if(session != null) session.close();
            if(connection != null) connection.close();
            if(context != null) context.close();
        }
    }
{code}

>From what I gather from the address string docs, session.createConsumer() should throw a JMSException, right?

If I make the subscription non-durable (and no other changes), it succeeds:
{noformat}
destination.dontCreateTopicExchange = amq.topic / test-create-failure; { create: never, assert: always, node: { durable: True, type: topic }, mode: consume } {noformat}

Thanks!

  was:
I've been subscribing to a non-existing topic using { create: never}, and the topic subscription succeeds. Here's the address string in the properties file I'm using:
{noformat}
destination.dontCreateTopicExchange = amq.topic / test-create-failure; { create: never }
{noformat}

Here's the junit test:
{code:java}
    @Test
    public void testSubscriptionCannotBeCreatedWithCreateNever() throws Exception {
        Context context = null;
        Session session = null;
        Connection connection = null;
        MessageConsumer messageConsumer = null;
        
        try {
            Properties properties = new Properties();
            properties.load(this.getClass().getResourceAsStream("/hello.properties"));
            context = new InitialContext(properties);

            ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("qpidConnectionfactory");
            connection = connectionFactory.createConnection();
            connection.start();

            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Destination destination = (Destination)context.lookup("dontCreateTopicExchange");

            Topic topic = (Topic)destination;
            System.out.println("Subscribing to topic (" + topic.toString() + ") " + topic.getTopicName());

            try {
                messageConsumer = session.createConsumer((Topic)destination);
                // should not have gotten this far
                Assert.fail("Expected Session.createConsumer() to fail, but it succeeded.");
            }
            catch(JMSException e) { }

        }
        finally {
            if(messageConsumer != null) messageConsumer.close();
            if(session != null) session.close();
            if(connection != null) connection.close();
            if(context != null) context.close();
        }
    }
{code}

>From what I gather from the address string docs, session.createConsumer() should throw a JMSException, right?

Thanks!

        Summary: Creating a durable subscription when the topic address has '{create: never}' creates the subscription anyways.  (was: Creating a subscription when the topic address has '{create: never}' creates the subscription anyways.)

Updated address string to show how durable makes the test fail, and made sure assert: always is in place.

> Creating a durable subscription when the topic address has '{create: never}' creates the subscription anyways.
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: QPID-5510
>                 URL: https://issues.apache.org/jira/browse/QPID-5510
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: 0.27
>         Environment: Client: OSX 10.9.1, Java 1.7.0_15 - using qpid-client 0.24 from Maven
> Server: Ubuntu 12.04.3, OpenJDK 2.3.10 - using trunk Java broker
>            Reporter: Logan Barnett
>
> I've been subscribing to a non-existing topic, and the topic subscription succeeds. Here's the address string in the properties file I'm using:
> {noformat}
> destination.dontCreateTopicExchange = amq.topic / test-create-failure; { create: never, assert: always, node: { durable: True, type: topic }, mode: consume } {noformat}
> Here's the junit test:
> {code:java}
>     @Test
>     public void testSubscriptionCannotBeCreatedWithCreateNever() throws Exception {
>         Context context = null;
>         Session session = null;
>         Connection connection = null;
>         MessageConsumer messageConsumer = null;
>         
>         try {
>             Properties properties = new Properties();
>             properties.load(this.getClass().getResourceAsStream("/hello.properties"));
>             context = new InitialContext(properties);
>             ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("qpidConnectionfactory");
>             connection = connectionFactory.createConnection();
>             connection.start();
>             session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>             Destination destination = (Destination)context.lookup("dontCreateTopicExchange");
>             Topic topic = (Topic)destination;
>             System.out.println("Subscribing to topic (" + topic.toString() + ") " + topic.getTopicName());
>             try {
>                 messageConsumer = session.createConsumer((Topic)destination);
>                 // should not have gotten this far
>                 Assert.fail("Expected Session.createConsumer() to fail, but it succeeded.");
>             }
>             catch(JMSException e) { }
>         }
>         finally {
>             if(messageConsumer != null) messageConsumer.close();
>             if(session != null) session.close();
>             if(connection != null) connection.close();
>             if(context != null) context.close();
>         }
>     }
> {code}
> From what I gather from the address string docs, session.createConsumer() should throw a JMSException, right?
> If I make the subscription non-durable (and no other changes), it succeeds:
> {noformat}
> destination.dontCreateTopicExchange = amq.topic / test-create-failure; { create: never, assert: always, node: { durable: True, type: topic }, mode: consume } {noformat}
> Thanks!



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org