[ 
https://issues.apache.org/activemq/browse/AMQ-2561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=56951#action_56951
 ] 

SuoNayi Wang edited comment on AMQ-2561 at 1/16/10 1:46 PM:
------------------------------------------------------------

Thanks Davies!
To reproduce, I deploy a completely new AMQ 5.2.0 application on server  and 
drop all tables created by AMQ automatically.
then I start AMQ  and run the test case Producer.java.
It works fine. Subscriber does not receive message sent by the same connection.
The information displayed in the console:
---------------------------------------------------------------------------------------------------------------
Send a message ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = ID:suonayi-826da47-5000-1263649149250-0:0:1:1:1, 
originalDestination = null, originalTransactionId = null, producerId = null, 
destination = topic://topicA, transactionId = null, expiration = 0, timestamp = 
1263649150000, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= null, replyTo = null, persistent = true, type = null, priority = 4, groupID = 
null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = 
null, content = null, marshalledProperties = null, dataStructure = null, 
redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, 
readOnlyBody = false, droppable = false, text = THIS IS A TEST}
---------------------------------------------------------------------------------------------------------------
I restart Producer.java again. Subscriber does receive message sent by itself 
this time.
The information displayed in the console:
---------------------------------------------------------------------------------------------------------------
Send a message ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = ID:suonayi-826da47-1046-1263649222250-0:0:1:1:1, 
originalDestination = null, originalTransactionId = null, producerId = null, 
destination = topic://topicA, transactionId = null, expiration = 0, timestamp = 
1263649223250, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= null, replyTo = null, persistent = true, type = null, priority = 4, groupID = 
null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = 
null, content = null, marshalledProperties = null, dataStructure = null, 
redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, 
readOnlyBody = false, droppable = false, text = THIS IS A TEST}

Receive a message ActiveMQTextMessage {commandId = 6, responseRequired = true, 
messageId = ID:suonayi-826da47-1046-1263649222250-0:0:1:1:1, 
originalDestination = null, originalTransactionId = null, producerId = 
ID:suonayi-826da47-1046-1263649222250-0:0:1:1, destination = topic://topicA, 
transactionId = null, expiration = 0, timestamp = 1263649223250, arrival = 0, 
brokerInTime = 1263649053526, brokerOutTime = 1263649053531, correlationId = 
null, replyTo = null, persistent = true, type = null, priority = 4, groupID = 
null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = 
null, content = null, marshalledProperties = null, dataStructure = null, 
redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, 
readOnlyBody = true, droppable = false, text = THIS IS A TEST}
---------------------------------------------------------------------------------------------------------------
Please notice that messageId  is the same with the message sent to broker and 
received by messagelistener.


      was (Author: wangyin):
    Thanks Davies,I have figured out what happened.
To reproduce, I deploy a completely new AMQ 5.2.0 application on server  and 
drop all tables created by AMQ automatically.
then I start AMQ  and run the test case Producer.java.
It works fine. Subscriber does not receive message sent by the same connection.
I restart Producer.java again. Subscriber  receive message sent by itself last 
time.
So it seems I have made a mistake.
:)

  
> Subscriber receives messages that sent by itself even if noLocal is true.
> -------------------------------------------------------------------------
>
>                 Key: AMQ-2561
>                 URL: https://issues.apache.org/activemq/browse/AMQ-2561
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.2.0
>            Reporter: SuoNayi Wang
>            Assignee: Rob Davies
>             Fix For: 5.4.0
>
>         Attachments: Producer.java
>
>
> 1, use org.springframework.jms.connection.SingleConnectionFactory to wrap 
> org.apache.activemq.spring.ActiveMQConnectionFactory so that we only use 
> single connection.
> 2, use org.springframework.jms.core.JmsTemplate to send a simple text message.
> 3, use org.springframework.jms.listener.DefaultMessageListenerContainer to 
> receive message,
>       <bean id="defaultMessageListenerContainer" 
> class="org.springframework.jms.listener.DefaultMessageListenerContainer">
>               <property name="connectionFactory" ref="connectionFactory"/>
>               <property name="sessionTransacted" value="true"/>
>               <property name="pubSubDomain" value="true"/>
>               <property name="pubSubNoLocal" value="true"/>
>               <property name="destination" ref="topicDestination"/>
>               <property name="subscriptionDurable" value="true"/>
>               <property name="durableSubscriptionName" value="bus.topic"/>
>               <property name="messageListener">
>                       <bean 
> class="com.sinosoft.activemq.listener.DefaultMessageListener"/>
>               </property>
>       </bean>
> 4, messageListener receive messages sent by itself.
> Also,to reproduce:
> package test;
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.Message;
> import javax.jms.MessageListener;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> import javax.jms.Topic;
> import javax.jms.TopicSubscriber;
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.command.ActiveMQTopic;
> public final class Producer implements MessageListener{
>     private Producer() {
>     }
>     public static void main(String[] args) {
>         String url = "failover:(tcp://172.31.0.82:61610)";
>         ConnectionFactory connectionFactory = new 
> ActiveMQConnectionFactory(url);
>         Topic destination = new ActiveMQTopic("bus.topic");
>         
>         Connection connection = null;
>         try{
>               connection = connectionFactory.createConnection();
>               connection.setClientID("112234");
>               
>               Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
>               
>               TopicSubscriber subscriber = 
> session.createDurableSubscriber(destination, "topicUser2", null, true);
>               System.out.println(subscriber + " getNoLocal()= " + 
> subscriber.getNoLocal());
>               Producer listener = new Producer();
>               subscriber.setMessageListener(listener);
>               
>               connection.start();
>               
>               MessageProducer producer = session.createProducer(destination);
>               TextMessage message = session.createTextMessage("THIS IS A 
> TEST");
>               producer.send(message);
>               producer.close();
>               System.out.println("Send a message " + message);
>         }catch(Exception e){
>               e.printStackTrace();
>         }
>     }
>       public void onMessage(Message msg){
>               System.out.println("Receive a message " + msg);
>       }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to