java mq 配置方式

最近用到mq,需要配置一些参数,开始时xml配置方式的,用的jar包是spring-rabbit 1.4.5.RELEASE,配置文件如下:

	
	
	
		
		
		
		
	
	
	
	
		
	
	
	
	
	
	
		
		
		
		
		
			
		
	

	
	
		
		
		
	
	
	
		
			
				devicePropertyQueue
			
		
		
		
		
		
	

感觉方式太low了,xml文件就是繁琐,后面改了一下,用spring-rabbit 2.0.5.RELEASE以上的版本,配置方式

配置文件如下:

mq.queue = push_device_property1
mq.exchange = deviceProperty.direct1
mq.routingkey = push_device_property1
mq.durable = true
mq.exclusive = false
mq.autoDelete = false

java里面配置如下:

    @RabbitListener(bindings = {
            @QueueBinding(value = @Queue(value = "${mq.queue}", durable = "${mq.durable}", autoDelete = "${mq.autoDelete}", exclusive = "${mq.exclusive}"),
                    exchange = @Exchange(name = "${mq.exchange}"), key = "${mq.routingkey}")})
    @RabbitHandler

 

你可能感兴趣的:(云平台开发)