本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}