/** * 站内信 * @param mm */ public void sendMessage(MiaoshaMessage mm) { // String msg = RedisService.beanToString(mm); log.info("send message:"+"11111"); rabbitTemplate.convertAndSend(MQConfig.EXCHANGE_TOPIC,"miaosha_*", "111111111"); }
/** Creates an instrumented {@linkplain RabbitTemplate} */ public RabbitTemplate newRabbitTemplate(ConnectionFactory connectionFactory) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); TracingMessagePostProcessor tracingMessagePostProcessor = new TracingMessagePostProcessor(this); rabbitTemplate.setBeforePublishPostProcessors(tracingMessagePostProcessor); return rabbitTemplate; }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { System.out.println(" [x] Requesting fib(" + start + ")"); Integer response = (Integer) template.convertSendAndReceive(exchange.getName(), "rpc", start++); System.out.println(" [.] Got '" + response + "'"); }
/** * the basic.return is sent to the client before basic.ack */ @PostConstruct public void postConstruct() { // return rabbitTemplate.setReturnCallback(new RabbitReturnCallback()); // ack rabbitTemplate.setConfirmCallback(new RabbitConfirmCallback()); }
public void setMessageConverter(MessageConverter messageConverter) { if (this.amqpTemplate instanceof RabbitTemplate) { ((RabbitTemplate) this.amqpTemplate).setMessageConverter(messageConverter); } else if (logger.isInfoEnabled()) { logger.info("AmqpTemplate is not a RabbitTemplate, so configured MessageConverter will be ignored."); } }
@Override public void enqueue(PriorityMessage item) { template.send("", name, item); }
public void setConnectionFactory(ConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; if (this.amqpTemplate instanceof RabbitTemplate) { ((RabbitTemplate) this.amqpTemplate).setConnectionFactory(this.connectionFactory); } }
public void setTemplateChannelTransacted(boolean channelTransacted) { if (this.amqpTemplate instanceof RabbitTemplate) { ((RabbitTemplate) this.amqpTemplate).setChannelTransacted(channelTransacted); } else if (logger.isInfoEnabled()) { logger.info("AmqpTemplate is not a RabbitTemplate, so configured 'channelTransacted' will be ignored."); } }
public void setEncoding(String encoding) { if (this.amqpTemplate instanceof RabbitTemplate) { ((RabbitTemplate) this.amqpTemplate).setEncoding(encoding); } else if (logger.isInfoEnabled()) { logger.info("AmqpTemplate is not a RabbitTemplate, so configured 'encoding' value will be ignored."); } }
rabbitTemplate.setBeforePublishPostProcessors(tracingMessagePostProcessor); return rabbitTemplate; newProcessors.addAll(processors); newProcessors.add(tracingMessagePostProcessor); rabbitTemplate.setBeforePublishPostProcessors( newProcessors.toArray(new MessagePostProcessor[0]) );
@Override public org.springframework.amqp.core.Message doSendAndReceiveWithTemporary(String exchange, String routingKey, org.springframework.amqp.core.Message message, CorrelationData correlationData) { return super.doSendAndReceiveWithTemporary(exchange, routingKey, message, correlationData); }
public void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter) { this.messagePropertiesConverter = messagePropertiesConverter; if (this.amqpTemplate instanceof RabbitTemplate) { ((RabbitTemplate) this.amqpTemplate).setMessagePropertiesConverter(messagePropertiesConverter); } }
/** * 站内信 * @param */ public void sendRegisterMessage(MiaoShaMessageVo miaoShaMessageVo) { String msg = RedisService.beanToString(miaoShaMessageVo); log.info("send message:{}" , msg); rabbitTemplate.convertAndSend(MQConfig.MIAOSHATEST,msg); // rabbitTemplate.convertAndSend(MQConfig.EXCHANGE_TOPIC,"miaosha_*", msg); } }
/** * 发布消息至Broker,通常由定时器扫描发送 */ public void publish(Event event, String exchange, String routeKey, CorrelationData correlationData) { Preconditions.checkNotNull(event); Preconditions.checkNotNull(exchange); Preconditions.checkNotNull(routeKey); HibernateValidators.throwsIfInvalid(event); rabbitTemplate.convertAndSend(exchange, routeKey, event, correlationData); }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { String message = "Hello World!"; this.template.convertAndSend(queue.getName(), message); System.out.println(" [x] Sent '" + message + "'"); }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { StringBuilder builder = new StringBuilder("Hello to "); if (this.index.incrementAndGet() == 3) { this.index.set(0); } String key = keys[this.index.get()]; builder.append(key).append(' '); builder.append(this.count.incrementAndGet()); String message = builder.toString(); template.convertAndSend(direct.getName(), key, message); System.out.println(" [x] Sent '" + message + "'"); }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { StringBuilder builder = new StringBuilder("Hello to "); if (this.index.incrementAndGet() == keys.length) { this.index.set(0); } String key = keys[this.index.get()]; builder.append(key).append(' '); builder.append(this.count.incrementAndGet()); String message = builder.toString(); template.convertAndSend(topic.getName(), key, message); System.out.println(" [x] Sent '" + message + "'"); }
@Override public void run(String... args) throws Exception { System.out.println("Sending message..."); rabbitTemplate.convertAndSend(SpringbootRabbitmqApplication.queueName, "Hello from RabbitMQ!"); receiver.getLatch().await(10000, TimeUnit.MILLISECONDS); context.close(); }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { StringBuilder builder = new StringBuilder("Hello"); if (dots.getAndIncrement() == 3) { dots.set(1); } for (int i = 0; i < dots.get(); i++) { builder.append('.'); } builder.append(count.incrementAndGet()); String message = builder.toString(); template.convertAndSend(queue.getName(), message); System.out.println(" [x] Sent '" + message + "'"); }
@Scheduled(fixedDelay = 1000, initialDelay = 500) public void send() { StringBuilder builder = new StringBuilder("Hello"); if (dots.getAndIncrement() == 3) { dots.set(1); } for (int i = 0; i < dots.get(); i++) { builder.append('.'); } builder.append(count.incrementAndGet()); String message = builder.toString(); template.convertAndSend(fanout.getName(), "", message); System.out.println(" [x] Sent '" + message + "'"); }