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


Java AmqpTemplate类代码示例

本文整理汇总了Java中org.springframework.amqp.core.AmqpTemplate的典型用法代码示例。如果您正苦于以下问题:Java AmqpTemplate类的具体用法?Java AmqpTemplate怎么用?Java AmqpTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
/**
 * @param args
 * @throws InterruptedException
 * @date 2017年7月13日 下午3:44:02
 * @writer junehappylove
 */
public static void main(String[] args) throws InterruptedException {
	context = new ClassPathXmlApplicationContext("amqp/amqp-producer.xml");
	AmqpTemplate template = (AmqpTemplate) context.getBean("rabbitTemplate");
	for (int i = 0; i < 2; i++) {
		System.out.println("Sending message #" + i);
		Spittle spittle = new Spittle((long) i, null, "Hello world (" + i + ")", new Date());
		template.convertAndSend(spittle);
		Thread.sleep(2000);
	}
	System.out.println("Done!");
	
	System.out.println("Direct...");
	MQProducer mqProducer = (MQProducer) context.getBean("mqProducer");
	mqProducer.sendDataToQueue("spring.test.queueKey1", "Hello World spring.test.queueKey1");
	mqProducer.sendDataToQueue("spring.test.queueKey2", "Hello World spring.test.queueKey2");
	System.out.println("routing done");
}
 
开发者ID:pudoj,项目名称:june.mq,代码行数:24,代码来源:ProducerMain.java

示例2: getObject

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Override
public AmqpTemplate getObject() throws Exception {
    RabbitTemplate rabbitTemplate = rabbitAdmin.getRabbitTemplate();
    rabbitTemplate.setMessageConverter(messageConverter);
    rabbitTemplate.setRetryTemplate(retryTemplate());

    if (messagingConfiguration.isMandatoryMessages()) {
        logger.info("will send mandatoryMessages, which expect at least one consumer");

        rabbitTemplate.setMandatory(true);
        rabbitTemplate.setReturnCallback(createReturnCallback());
    } else {
        logger.info("mandatory flag is not set, messages are not being set as mandatory");
    }

    return rabbitTemplate;
}
 
开发者ID:zeroDivisible,项目名称:spring-rabbitmq-example,代码行数:18,代码来源:AmqpTemplateFactory.java

示例3: changeExecutionOfMethodToUsePostProcessor

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
private boolean changeExecutionOfMethodToUsePostProcessor(
    ProceedingJoinPoint call, ArgumentDiscover argumentDiscover) {
  final Object[] args = call.getArgs();
  final String exchange = argumentDiscover.exchangeOfSender;
  final String routingKey = argumentDiscover.routingKey;
  final SpanManagerMessagePostProcessor beforePublishPostProcessor =
      new SpanManagerMessagePostProcessor(spanManager, buildSpanName(exchange, routingKey));
  final AmqpTemplate amqpTemplate = (AmqpTemplate) call.getTarget();

  boolean executed = true;
  final int argsLength = args.length;
  switch (argsLength) {
    case 1:
      amqpTemplate.convertAndSend(args[0], beforePublishPostProcessor);
      break;
    case 2:
      amqpTemplate.convertAndSend((String) args[0], args[1], beforePublishPostProcessor);
      break;
    case 3:
      amqpTemplate.convertAndSend(
          (String) args[0], (String) args[1], args[2], beforePublishPostProcessor);
      break;
    default:
      executed = false;
      break;
  }
  return executed;
}
 
开发者ID:netshoes,项目名称:spring-cloud-sleuth-amqp,代码行数:29,代码来源:AmqpTemplateAspect.java

示例4: ProfileServiceV1

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public ProfileServiceV1(ProfileRepository profileRepository, CustomerClient customerClient,
                        OAuth2RestTemplate oAuth2RestTemplate, AmqpTemplate amqpTemplate) {
    this.profileRepository = profileRepository;
    this.customerClient = customerClient;
    this.oAuth2RestTemplate = oAuth2RestTemplate;
    this.amqpTemplate = amqpTemplate;
}
 
开发者ID:kbastani,项目名称:cloud-native-microservice-strangler-example,代码行数:9,代码来源:ProfileServiceV1.java

示例5: amqpOutboundEndpoint

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Bean
@ServiceActivator(inputChannel = "outboundRequests")
public AmqpOutboundEndpoint amqpOutboundEndpoint(AmqpTemplate template) {
	AmqpOutboundEndpoint endpoint = new AmqpOutboundEndpoint(template);

	endpoint.setExpectReply(true);
	endpoint.setOutputChannel(inboundRequests());

	endpoint.setRoutingKey("partition.requests");

	return endpoint;
}
 
开发者ID:mminella,项目名称:java-remote-partitioning,代码行数:13,代码来源:JobConfiguration.java

示例6: amqpTemplate

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Bean
AmqpTemplate amqpTemplate() {
    ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
    policy.setInitialInterval(500);
    policy.setMaxInterval(10000);
    policy.setMultiplier(10);

    RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setBackOffPolicy(policy);

    RabbitTemplate template = new RabbitTemplate(getAmqpConnectionFactory());
    template.setRetryTemplate(retryTemplate);

    return template;
}
 
开发者ID:Byteflair,项目名称:resthooks,代码行数:16,代码来源:AmqpConfig.java

示例7: main

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
public static void main(String[] args) {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("testContext.xml");
    connectionFactory = (ConnectionFactory) applicationContext.getBean("amqpConnectionFactory");
    template = (AmqpTemplate) applicationContext.getBean("amqpTemplate");
    template.convertAndSend("Ben.Temp.Queue", "foo");
    ((CachingConnectionFactory) connectionFactory).destroy();
    System.out.println("done.");
    //System.exit();
}
 
开发者ID:benwilcock,项目名称:axon-cqrs-sample,代码行数:10,代码来源:TestRunner.java

示例8: Receiver

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public Receiver(ObjectMapper objectMapper, AmqpTemplate amqpTemplate, Twitter twitter, FollowsRepository followsRepository, TwitterService twitterService, UserRepository userRepository) {
    this.objectMapper = objectMapper;
    this.amqpTemplate = amqpTemplate;
    this.twitter = twitter;
    this.followsRepository = followsRepository;
    this.twitterService = twitterService;
    this.userRepository = userRepository;
}
 
开发者ID:kbastani,项目名称:spring-boot-graph-processing-example,代码行数:10,代码来源:Receiver.java

示例9: RabbitMQScheduler

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public RabbitMQScheduler(AmqpTemplate amqpTemplate, RabbitConfig config, RabbitAdmin admin) {
    this.amqpTemplate = amqpTemplate;
    this.config = config;
    this.admin = admin;
}
 
开发者ID:laidu,项目名称:java-learn,代码行数:7,代码来源:RabbitMQScheduler.java

示例10: setAmqpTemplate

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
public void setAmqpTemplate(AmqpTemplate amqpTemplate) {
    this.amqpTemplate = amqpTemplate;
}
 
开发者ID:yu199195,项目名称:myth,代码行数:4,代码来源:RabbitmqSendServiceImpl.java

示例11: MqProducer

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public MqProducer(AmqpAdmin amqpAdmin, AmqpTemplate amqpTemplate) {
    this.amqpAdmin = amqpAdmin;
    this.amqpTemplate = amqpTemplate;
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:6,代码来源:MqProducer.java

示例12: setAmqpTemplate

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
public void setAmqpTemplate(AmqpTemplate aAmqpTemplate) {
  amqpTemplate = aAmqpTemplate;
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:4,代码来源:AmqpMessenger.java

示例13: Sender

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public Sender(AmqpTemplate rabbitTemplate) {
    this.rabbitTemplate = rabbitTemplate;
}
 
开发者ID:xiaomoinfo,项目名称:SpringBootUnity,代码行数:5,代码来源:Sender.java

示例14: amqpService

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Bean
@Autowired
AmqpService amqpService(AmqpAdmin amqpAdmin, ConnectionFactory connectionFactory, AmqpTemplate amqpTemplate) {
    return new AmqpService(amqpAdmin, connectionFactory, amqpTemplate);
}
 
开发者ID:Byteflair,项目名称:resthooks,代码行数:6,代码来源:AmqpConfig.java

示例15: AmqpQueueCleaner

import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public AmqpQueueCleaner(AmqpTemplate amqpTemplate) {
    this.amqpTemplate = requireNonNull(amqpTemplate);
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:5,代码来源:AmqpQueueCleaner.java


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