You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by abhijith <to...@gmail.com> on 2016/04/29 17:13:32 UTC
Artemis create topic programatically
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.
Re: Artemis create topic programatically
Posted by Justin Bertram <jb...@apache.com>.
Automatically creating JMS server-side topics is not currently supported. See https://issues.apache.org/jira/browse/ARTEMIS-322 for more details.
Justin
----- Original Message -----
From: "abhijith" <to...@gmail.com>
To: users@activemq.apache.org
Sent: Friday, April 29, 2016 10:13:32 AM
Subject: Artemis create topic programatically
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.