activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tracyjoy <tracy...@126.com>
Subject Re: destinationURI parameter is not work(priority,exclusive)
Date Tue, 28 Jul 2009 13:29:30 GMT

activemq 5.2

rajdavies wrote:
> 
> Which version of activemq ?
> On 28 Jul 2009, at 04:00, tracyjoy wrote:
> 
>>
>> hi,all:
>>  i write a class to test exclusive and priority,but all i set are not
>> work,all messages i producted are shared by customers.this is my code:
>>
>> package com.test;
>>
>> import javax.jms.Connection;
>> import javax.jms.ConnectionFactory;
>> import javax.jms.DeliveryMode;
>> import javax.jms.Destination;
>> import javax.jms.Message;
>> import javax.jms.MessageConsumer;
>> import javax.jms.MessageListener;
>> import javax.jms.Session;
>>
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> import org.apache.activemq.command.ActiveMQQueue;
>>
>> public class Customer implements MessageListener {
>> 	
>> 	private static ConnectionFactory connFactory;
>> 	private String connectionURI="tcp://localhost:61616";
>> 	private String queueName="TEST.PRODUCER";
>> 	private boolean transacted=false;
>> 	private int ackMode=Session.AUTO_ACKNOWLEDGE;
>> 	private int durable=DeliveryMode.PERSISTENT;
>> 	private String customerName;
>> 	
>> 	private int count=0;
>> 	
>> 	{
>> 		connFactory=new ActiveMQConnectionFactory(connectionURI);
>> 	}
>> 	
>> 	public Customer(String name){
>> 		this.customerName=name;
>> 	}
>> 	
>> 	public void run(){
>> 		try {
>> 			Connection conn=connFactory.createConnection();
>> 			Session session= conn.createSession(transacted, ackMode);
>> 			Destination queue=new ActiveMQQueue(queueName);
>> 			MessageConsumer customer=session.createConsumer(queue);
>> 			customer.setMessageListener(this);
>> 			System.out.println(customerName+" start for listening");
>> 			conn.start();
>> 		} catch (Exception e) {
>> 			e.printStackTrace();
>> 		}
>> 		
>> 	}
>> 	
>> 	public void onMessage(Message arg0) {
>> 		System.out.println(customerName+" receive a message NO. is "+count);
>> 		count++;
>> 	}	
>> 	
>> 	public void addDestinationURIParamters(String key,Object value){
>> 		if(this.queueName.indexOf("?")==-1){
>> 			this.queueName=this.queueName+"?"+key+"="+value;
>> 		}else{
>> 			this.queueName=this.queueName+"&"+key+"="+value;
>> 		}
>> 		System.out.println(customerName+" destinationURL is  
>> "+this.queueName);
>> 	}
>> 	
>> 	public static void main(String[] args){
>> 		Customer firstCustomer=new Customer("firstCustomer");
>> //		firstCustomer.addDestinationURIParamters("customer.priority","3");
>> 		Customer secondCustomer=new Customer("secondCustomer");
>> //		 
>> secondCustomer.addDestinationURIParamters("customer.priority","2");
>> 		Customer thirdCustomer=new Customer("thirdCustomer");
>> //		thirdCustomer.addDestinationURIParamters("customer.priority","1");
>> 		 
>> secondCustomer.addDestinationURIParamters("customer.exclusive",true);
>> 		firstCustomer.run();
>> 		secondCustomer.run();
>> 		thirdCustomer.run();
>> 	}
>>
>> }
>> -- 
>> View this message in context:
>> http://www.nabble.com/destinationURI-parameter-is-not-work%28priority%2Cexclusive%29-tp24691751p24691751.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
> 
> Rob Davies
> I work here: http://fusesource.com
> My Blog: http://rajdavies.blogspot.com/
> I'm writing this: http://www.manning.com/snyder/
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/destinationURI-parameter-is-not-work%28priority%2Cexclusive%29-tp24691751p24698082.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message