[ 
https://issues.apache.org/jira/browse/ARTEMIS-322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15057150#comment-15057150
 ] 

Roan edited comment on ARTEMIS-322 at 12/15/15 1:41 AM:
--------------------------------------------------------

Hi Clebert,

I'm sorry about that, I'm new one day on this.
I will try to explain better, I'm trying to implement and Junit test as a 
method above. When I'm using the ActiveMQ Artemis core lib, I was debugging the 
code because every time I'm getting the error code:
{panel:title=My 
Exception|borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1|bgColor=#FFFFCE}
javax.jms.JMSException: There is no topic with name topic
        at 
org.apache.activemq.artemis.jms.client.ActiveMQSession.createTopic(ActiveMQSession.java:373)
        at com.redhat.messaging.topicagents.Publisher.create(Publisher.java:52)
        at 
com.redhat.messaging.ArtemisRedHatTopicTestCase.testSendTextMessageToDestination(ArtemisRedHatTopicTestCase.java:29)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at junit.framework.TestCase.runTest(TestCase.java:176)
        at junit.framework.TestCase.runBare(TestCase.java:141)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:252)
        at junit.framework.TestSuite.run(TestSuite.java:247)
        at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
{panel}

As you can see, I created a topic called topic on my code bellow:
{code:borderStyle=solid}
          // create a Session
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // create the Topic to which messages will be sent
        Topic topic = session.createTopic("topic");
{code}

I debbuged and I would like a help to fix it, on package 
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl who package 
org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext on 
line 243 has a piece of code
{code}
public ClientSession.AddressQuery addressQuery(final SimpleString address) 
throws ActiveMQException {
      SessionBindingQueryResponseMessage_V2 response = 
(SessionBindingQueryResponseMessage_V2) sessionChannel.sendBlocking(new 
SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V2);

      return new AddressQueryImpl(response.isExists(), 
response.getQueueNames(), response.isAutoCreateJmsQueues());
   }
{code}

this response value is not comming with values, and I understand should return 
that my topic exists. Because I'd created a temporary topic as I told you 
before.


was (Author: roanbrasil):
Hi Clebert,

I'm sorry about that, I'm new one day on this.
I will try to explain better, I'm trying to implement and Junit test as a 
method above. When I'm using the ActiveMQ Artemis core lib, I was debugging the 
code because every time I'm getting the error code:
{panel:title=My 
Title|borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1|bgColor=#FFFFCE}
javax.jms.JMSException: There is no topic with name topic
        at 
org.apache.activemq.artemis.jms.client.ActiveMQSession.createTopic(ActiveMQSession.java:373)
        at com.redhat.messaging.topicagents.Publisher.create(Publisher.java:52)
        at 
com.redhat.messaging.ArtemisRedHatTopicTestCase.testSendTextMessageToDestination(ArtemisRedHatTopicTestCase.java:29)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at junit.framework.TestCase.runTest(TestCase.java:176)
        at junit.framework.TestCase.runBare(TestCase.java:141)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:252)
        at junit.framework.TestSuite.run(TestSuite.java:247)
        at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
{panel}

As you can see, I created a topic called topic on my code bellow:
{code:borderStyle=solid}
          // create a Session
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // create the Topic to which messages will be sent
        Topic topic = session.createTopic("topic");
{code}

I debbuged and I would like a help to fix it, on package 
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl who package 
org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext on 
line 243 has a piece of code
{code}
public ClientSession.AddressQuery addressQuery(final SimpleString address) 
throws ActiveMQException {
      SessionBindingQueryResponseMessage_V2 response = 
(SessionBindingQueryResponseMessage_V2) sessionChannel.sendBlocking(new 
SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V2);

      return new AddressQueryImpl(response.isExists(), 
response.getQueueNames(), response.isAutoCreateJmsQueues());
   }
{code}

this response value is not comming with values, and I understand should return 
that my topic exists. Because I'd created a temporary topic as I told you 
before.

> Topic Junit Test 
> -----------------
>
>                 Key: ARTEMIS-322
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-322
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 1.1.0
>         Environment: CentOS, Java 1.7, Eclipse, Artemis 1.1.0
>            Reporter: Roan
>              Labels: newbie
>
> I was running a Topic example, as listed bellow.
> {code:title=TestCase.java|borderStyle=solid}
> @Test
>       public void testSendTextMessageToDestination() throws Exception {
>               Publisher pub = new Publisher();
>               pub.create("5", "topic");
>               pub.sendName("Roan", "Monteiro");
>               String greeting1 = new Subscriber().getGreeting(1000);
>               assertEquals("Hello Roan Monteiro!", greeting1);
>               pub.closeConnection();
>       }
> {code}
> Where my publisher and subscriber are:
> {code:title=Publisher.java|borderStyle=solid}
> package com.redhat.messaging.topicagents;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.jms.Topic;
> import org.apache.activemq.artemis.api.core.TransportConfiguration;
> import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
> import org.apache.activemq.artemis.api.jms.JMSFactoryType;
> import 
> org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> /**
>  * Non-Durable Subscrition
>  * @author roanbrasil
>  *
>  */
> public class Publisher {
>     private static final Logger LOGGER = LoggerFactory
>             .getLogger(Publisher.class);
>     private String clientId;
>     private Connection connection;
>     private Session session;
>     private MessageProducer messageProducer;
>     public void create(String clientId, String topicName) throws JMSException 
> {
>         this.clientId = clientId;
>         // create a Connection Factory
>         TransportConfiguration transportConfiguration = new 
> TransportConfiguration(
>                               NettyConnectorFactory.class.getName());
>               ConnectionFactory cf = ActiveMQJMSClient
>                               
> .createConnectionFactoryWithoutHA(JMSFactoryType.TOPIC_CF,
>                                               transportConfiguration);
>         // create a Connection
>         connection = cf.createConnection();
>         connection.setClientID(clientId);
>         // create a Session
>         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>         // create the Topic to which messages will be sent
>         Topic topic = session.createTopic(topicName);
>         // create a MessageProducer for sending messages
>         messageProducer = session.createProducer(topic);
>     }
>     public void closeConnection() throws JMSException {
>         connection.close();
>     }
>     public void sendName(String firstName, String lastName) throws 
> JMSException {
>         String text = firstName + " " + lastName;
>         // create a JMS TextMessage
>         TextMessage textMessage = session.createTextMessage(text);
>         // send the message to the topic destination
>         messageProducer.send(textMessage);
>         LOGGER.debug(clientId + ": sent message with text='{}'", text);
>     }
> }
> {code}
> {code:title=Subscriber.java|borderStyle=solid}
> package com.redhat.messaging.topicagents;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageConsumer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.jms.Topic;
> import org.apache.activemq.artemis.api.core.TransportConfiguration;
> import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
> import org.apache.activemq.artemis.api.jms.JMSFactoryType;
> import 
> org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> public class Subscriber {
>     private static final Logger LOGGER = LoggerFactory
>             .getLogger(Subscriber.class);
>     private static final String NO_GREETING = "no greeting";
>     private String clientId;
>     private Connection connection;
>     private Session session;
>     private MessageConsumer messageConsumer;
>     public void create(String clientId, String topicName) throws JMSException 
> {
>         this.clientId = clientId;
>      // create a Connection Factory
>         TransportConfiguration transportConfiguration = new 
> TransportConfiguration(
>                               NettyConnectorFactory.class.getName());
>               ConnectionFactory cf = ActiveMQJMSClient
>                               
> .createConnectionFactoryWithoutHA(JMSFactoryType.TOPIC_CF,
>                                               transportConfiguration);
>         // create a Connection
>         connection = cf.createConnection();
>         connection.setClientID(clientId);
>         // create a Session
>         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>         // create the Topic from which messages will be received
>         Topic topic = session.createTopic(topicName);
>         // create a MessageConsumer for receiving messages
>         messageConsumer = session.createConsumer(topic);
>         // start the connection in order to receive messages
>         connection.start();
>     }
>     public void closeConnection() throws JMSException {
>         connection.close();
>     }
>     public String getGreeting(int timeout) throws JMSException {
>         String greeting = NO_GREETING;
>         // read a message from the topic destination
>         Message message = messageConsumer.receive(timeout);
>         // check if a message was received
>         if (message != null) {
>             // cast the message to the correct type
>             TextMessage textMessage = (TextMessage) message;
>             // retrieve the message content
>             String text = textMessage.getText();
>             LOGGER.debug(clientId + ": received message with text='{}'", 
> text);
>             // create greeting
>             greeting = "Hello " + text + "!";
>         } else {
>             LOGGER.debug(clientId + ": no message received");
>         }
>         LOGGER.info("greeting={}", greeting);
>         return greeting;
>     }
> }
> {code}
> When I got to ChannelImpl.class is created a temporary Topic which the name 
> is jms.temptopic.topic. On the packet variable the type is 49 and the channel 
> Id is 11. But the sendBlocking return the response variable with no 
> queueNames and setting exists as false, I believe this queueName should come 
> with topic name and the exists variable as true value.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to