當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。