本文整理汇总了Java中org.springframework.amqp.rabbit.core.RabbitTemplate.setReceiveTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java RabbitTemplate.setReceiveTimeout方法的具体用法?Java RabbitTemplate.setReceiveTimeout怎么用?Java RabbitTemplate.setReceiveTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.amqp.rabbit.core.RabbitTemplate
的用法示例。
在下文中一共展示了RabbitTemplate.setReceiveTimeout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replicationRabbitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate replicationRabbitTemplate(
ConnectionFactory connectionFactory,
MessageConverter replicationMessageConverter
) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setReceiveTimeout(listeningTimeout);
template.setExchange(replicationExchange);
template.setMessageConverter(replicationMessageConverter);
return template;
}
示例2: rabbitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate rabbitTemplate(
ConnectionFactory connectionFactory,
MessageConverter messageConverter
) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setReceiveTimeout(listeningTimeout);
template.setMessageConverter(messageConverter);
return template;
}
示例3: 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;
}
示例4: fileServerRabbitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate fileServerRabbitTemplate(
ConnectionFactory serverConnectionFactory,
MessageConverter fileServerMessageConverter
) {
RabbitTemplate template = new RabbitTemplate(serverConnectionFactory);
template.setReceiveTimeout(listeningTimeout);
template.setMessageConverter(fileServerMessageConverter);
return template;
}
示例5: createDmfClient
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
private RabbitTemplate createDmfClient() {
final RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setMessageConverter(new Jackson2JsonMessageConverter());
template.setReceiveTimeout(TimeUnit.SECONDS.toMillis(3));
template.setReplyTimeout(TimeUnit.SECONDS.toMillis(3));
template.setExchange(getExchange());
return template;
}
示例6: rabbitTemplateForTest
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
@Primary
public RabbitTemplate rabbitTemplateForTest(ConnectionFactory connectionFactory) {
final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
rabbitTemplate.setReplyTimeout(TimeUnit.SECONDS.toMillis(3));
rabbitTemplate.setReceiveTimeout(TimeUnit.SECONDS.toMillis(3));
return rabbitTemplate;
}
示例7: 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);
}
}