activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce Snyder (JIRA)" <j...@apache.org>
Subject [jira] Updated: (AMQ-2561) Subscriber receives messages that sent by itself even if noLocal is true.
Date Sat, 18 Sep 2010 16:46:43 GMT

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

Bruce Snyder updated AMQ-2561:
------------------------------

    Fix Version/s: 5.5.0
                       (was: 5.4.1)

> 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.5.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.


Mime
View raw message