当前位置: 首页>>代码示例>>Java>>正文


Java RabbitTemplate.setQueue方法代码示例

本文整理汇总了Java中org.springframework.amqp.rabbit.core.RabbitTemplate.setQueue方法的典型用法代码示例。如果您正苦于以下问题:Java RabbitTemplate.setQueue方法的具体用法?Java RabbitTemplate.setQueue怎么用?Java RabbitTemplate.setQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.amqp.rabbit.core.RabbitTemplate的用法示例。


在下文中一共展示了RabbitTemplate.setQueue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate() {
	RabbitTemplate template = new RabbitTemplate(connectionFactory());
	template.setQueue(this.queueName);
       template.setMessageConverter(jsonMessageConverter());
	return template;
}
 
开发者ID:microservices-demo,项目名称:queue-master,代码行数:8,代码来源:ShippingConsumerConfiguration.java

示例2: outRabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate outRabbitTemplate(
        ConnectionFactory outConnectionFactory,
        MessageConverter outMessageConverter
) {
    RabbitTemplate template = new RabbitTemplate(outConnectionFactory);
    template.setReceiveTimeout(listeningTimeout);
    template.setQueue(resultQueue);
    template.setMessageConverter(outMessageConverter);

    return template;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:AmqpBridgeOutputConfig.java

示例3: internalExecute

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
private void internalExecute(InsuranceTask task) throws JsonProcessingException {
	Assert.notNull(task.getData(), "Missing task data");
	String routingKey = task.getDestinationQueue();
	Object data = task.getData();
	String message = mapper.writeValueAsString(data);
	try {

		log.info("Sending message to {}", routingKey);
		RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
		rabbitTemplate.setReplyTimeout(5000);
		rabbitTemplate.setReceiveTimeout(5000);
		rabbitTemplate.setQueue(routingKey);

		// TODO
		boolean sync = false;

		if (sync) {
			Object response = rabbitTemplate.convertSendAndReceive(routingKey, message);
			log.info("Received message from {}: {}", routingKey, response);
		}
		else {
			rabbitTemplate.convertAndSend(routingKey, message);
			try {
				Thread.sleep(5000);
			}
			catch (InterruptedException e) {
			}
		}
	}
	catch (RuntimeException ex) {
		log.error("Task execution error using routingKey {}", routingKey);
		throw new InsuranceException("Task execution error", ex);
	}
}
 
开发者ID:labcabrera,项目名称:lab-insurance,代码行数:35,代码来源:InsuranceTaskExecutor.java

示例4: rabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate()
{
    RabbitTemplate template = new RabbitTemplate(connectionFactory());
    template.setRoutingKey(this.tasksQueue);
    template.setQueue(this.tasksQueue);
    template.setMessageConverter(jsonMessageConverter());
    return template;
}
 
开发者ID:BernhardWenzel,项目名称:scraping-microservice-java-python-rabbitmq,代码行数:10,代码来源:TaskProducerConfiguration.java

示例5: rabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate() {
	RabbitTemplate template = new RabbitTemplate(connectionFactory());
	template.setRoutingKey(this.scrapingResultQueue);
	template.setQueue(this.scrapingResultQueue);
       template.setMessageConverter(jsonMessageConverter());
	return template;
}
 
开发者ID:BernhardWenzel,项目名称:scraping-microservice-java-python-rabbitmq,代码行数:9,代码来源:ScrapingResultConsumerConfiguration.java

示例6: rabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate()
{
    RabbitTemplate template = new RabbitTemplate(connectionFactory());
    template.setRoutingKey(this.queueName);
    template.setQueue(this.queueName);
    template.setMessageConverter(jsonMessageConverter());
    return template;
}
 
开发者ID:osmmosques,项目名称:osm-mosques,代码行数:10,代码来源:SlackNotifierConfiguration.java

示例7: initRabbitMQ

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
private void initRabbitMQ() throws URISyntaxException {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory(new URI(host));

    Map<String, Object> cmdQueueArgs = new HashMap<>();
    cmdQueueArgs.put("x-max-length", maxSize);
    cmdQueueArgs.put("x-max-priority", maxPriority);
    Queue cmdQueue = new Queue(name, true, false, false, cmdQueueArgs);

    RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
    rabbitAdmin.declareQueue(cmdQueue);

    // setup listener container factory
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setConcurrentConsumers(DEFAULT_CONCURRENCY);
    factory.setMaxConcurrentConsumers(DEFAULT_CONCURRENCY);
    factory.setTaskExecutor(executor);
    factory.setAutoStartup(false);

    // setup rabbit template
    template = new RabbitTemplate(connectionFactory);
    template.setQueue(name);

    // setup container
    SimpleRabbitListenerEndpoint simpleEndpoint = new SimpleRabbitListenerEndpoint();
    simpleEndpoint.setMessageListener(new RabbitMessageListener());

    container = factory.createListenerContainer(simpleEndpoint);
    container.setQueueNames(name);
    LOGGER.trace("RabbitMQ initialized on '%s' with queue name '%s'", host, name);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:32,代码来源:RabbitQueue.java

示例8: rabbitTemplate

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setQueue(environment.getProperty("rabbitmq.queue"));
    return template;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:7,代码来源:SpringIntegrationConfig.java

示例9: sendMessage

import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
public void sendMessage(Message msg, String queue) {

        msg.getMessageProperties().setTimestamp(new Date());

        RabbitTemplate template = new RabbitTemplate(SingletonConnectionFactory.getConnection(host, username, password));
        template.setRoutingKey(queue);
        template.setQueue(queue);
        template.send(queue, queue, msg);

    }
 
开发者ID:visp-streaming,项目名称:dataProvider,代码行数:11,代码来源:RabbitMQSender.java


注:本文中的org.springframework.amqp.rabbit.core.RabbitTemplate.setQueue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。