本文整理汇总了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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例10: setAmqpTemplate
import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
public void setAmqpTemplate(AmqpTemplate amqpTemplate) {
this.amqpTemplate = amqpTemplate;
}
示例11: MqProducer
import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public MqProducer(AmqpAdmin amqpAdmin, AmqpTemplate amqpTemplate) {
this.amqpAdmin = amqpAdmin;
this.amqpTemplate = amqpTemplate;
}
示例12: setAmqpTemplate
import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
public void setAmqpTemplate(AmqpTemplate aAmqpTemplate) {
amqpTemplate = aAmqpTemplate;
}
示例13: Sender
import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public Sender(AmqpTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
}
示例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);
}
示例15: AmqpQueueCleaner
import org.springframework.amqp.core.AmqpTemplate; //导入依赖的package包/类
@Autowired
public AmqpQueueCleaner(AmqpTemplate amqpTemplate) {
this.amqpTemplate = requireNonNull(amqpTemplate);
}