本文整理汇总了Java中org.springframework.amqp.rabbit.core.RabbitTemplate.setExchange方法的典型用法代码示例。如果您正苦于以下问题:Java RabbitTemplate.setExchange方法的具体用法?Java RabbitTemplate.setExchange怎么用?Java RabbitTemplate.setExchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.amqp.rabbit.core.RabbitTemplate
的用法示例。
在下文中一共展示了RabbitTemplate.setExchange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
/**
* @Title: call
* @Description: call类型,点对点发送接收消息
* @param topicRoutingKey
* @param serverName
* @param bodyMsg
* @param outTimeMillis
* @throws Exception 设定文件
* @return Map<String,Object> 返回类型
*/
public Map<String,Object> call(String topicRoutingKey,String serverName,Map<String,Object> bodyMsg,int outTimeMillis) throws Exception{
Map<String,Object> sendMsg = new HashMap<String,Object>();
sendMsg.put("mqkey",topicRoutingKey+"."+serverName);
sendMsg.put("mqtype","call");
sendMsg.put("mqbody",bodyMsg==null?new HashMap<String,Object>():bodyMsg);
String topicMessage = JSON.toJSONString(sendMsg, JsonFilter.filter);
Message message=new Message(topicMessage.getBytes("UTF-8"),new MessageProperties());
RabbitTemplate directTemplate =new RabbitTemplate();
directTemplate.setConnectionFactory(connectionFactory);
directTemplate.setExchange(PropertyLoader.MQ_EXCHANGE);
directTemplate.setReplyTimeout(outTimeMillis);
Message reply=directTemplate.sendAndReceive(topicRoutingKey,message);
if(reply==null){
throw new Exception("waitting rabbitmq response timeout");
}
String body=new String(reply.getBody(),"UTF-8");
Map<String,Object> reqMsgMap =JSON.parseObject(body,new TypeReference<Map<String, Object>>(){});
LOG.info("back :"+reqMsgMap);
reqMsgMap =JSON.parseObject(reqMsgMap.get("mqbody").toString(),new TypeReference<Map<String, Object>>(){});
return reqMsgMap;
}
示例2: 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;
}
示例3: submitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate submitTemplate() {
RabbitTemplate bean = new RabbitTemplate(connectionFactory());
bean.setMessageConverter(jsonMessageConverter());
// para enviar, el binding del exchange se configura en el rabbitmq
// server a la cola correspondiente (que aqui no interesa)
bean.setExchange(env.getProperty("submit.exchange"));
return bean;
}
示例4: plagiarismDetectorTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
public RabbitTemplate plagiarismDetectorTemplate() {
RabbitTemplate bean = new RabbitTemplate(connectionFactory());
bean.setMessageConverter(jsonMessageConverter());
bean.setExchange(env.getProperty("plagiarism.detection.exchange"));
return bean;
}
示例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: rabbitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
RabbitTemplate rabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory cf,
ObjectMapper mapper) {
RabbitTemplate template = new RabbitTemplate(cf);
template.setExchange(EXCHANGE_NAME);
RetryTemplate retry = new RetryTemplate();
ExponentialBackOffPolicy backOff = new ExponentialBackOffPolicy();
backOff.setInitialInterval(1000);
backOff.setMultiplier(1.5);
backOff.setMaxInterval(60000);
retry.setBackOffPolicy(backOff);
template.setRetryTemplate(retry);
template.setMessageConverter(new Jackson2JsonMessageConverter(mapper));
return template;
}
示例7: fixedReplyQRabbitTemplate
import org.springframework.amqp.rabbit.core.RabbitTemplate; //导入方法依赖的package包/类
@Bean
RabbitTemplate fixedReplyQRabbitTemplate(Exchange exchange, @Qualifier(REPLY_Q) Queue replyQueue, ConnectionFactory connectionFactory) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setExchange(exchange.getName());
template.setRoutingKey(this.routingKey);
template.setReplyTimeout(-1); // this means that it should wait forever for a reply. TODO is this too dangerous ?
template.setReplyQueue(replyQueue);
return template;
}