Hi,

I am trying to create topic programatically.  Please find below my code

@Test
   public void testCreateTopic() throws Exception {
        ConnectionFactory cf =
ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, server1,
server2);
        Connection conn = cf.createConnection();

        Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);

        Topic topic = session.createTopic("TestTopic");

        String topicName = topic.getTopicName();

       
assertFalse(topicName.startsWith(ActiveMQDestination.JMS_TOPIC_ADDRESS_PREFIX));

        Topic replyTopic = session.createTopic(topicName);

        MessageConsumer consumer = session.createConsumer(replyTopic);

        conn.start();

        MessageProducer producer = session.createProducer(replyTopic);

        producer.send(session.createMessage());

        assertNotNull(consumer.receive(10000));
    }

I also have the right permissions 

<security-setting match="jms.topic.#">
            <permission type="createDurableQueue" roles="guest"/>
            <permission type="deleteDurableQueue" roles="guest"/>
            <permission type="createNonDurableQueue" roles="guest"/>
            <permission type="deleteNonDurableQueue" roles="guest"/>
            <permission type="consume" roles="guest"/>
            <permission type="send" roles="guest"/>
</security-setting>

But I keep getting the error 

"javax.jms.JMSException: There is no topic with name TestTopic".  Similar
code works for queues.  Please let me know if I am doing something wrong.

Thanks
Abhi





--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Artemis-create-topic-programatically-tp4711388.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to