我正在阅读以下文章 SPRING_BOOT_JMS_GETTING_STARTED
这个例子解释了如何开始使用嵌入式 ActiveMq 消息代理 但是我已经在我的 PC 上安装了 RabbitMq,我想使用这个。
首先我启用了jms rabbitMq插件
但是我在管理控制台中没有看到额外的交换:
因为 this answer,我希望看到它
老实说,我不知道我现在应该做什么。
我有一个来自入门的代码,我打开了 jms RabbitMq 插件。
请告诉我后续步骤。
小提示:
如果我使用以下 gradle 依赖项,Garry answer 会起作用:
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile group: 'org.springframework', name: 'spring-jms', version: '4.3.10.RELEASE'
compile group: 'com.rabbitmq.jms', name: 'rabbitmq-jms', version: '1.7.0'
}
最佳答案
在您实际使用之前,交易不会出现。我刚刚编写了一个快速启动应用程序,它对我来说运行良好...
@SpringBootApplication
public class RabbitJmsApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(RabbitJmsApplication.class, args);
}
@Autowired
private JmsTemplate template;
@Override
public void run(String... arg0) throws Exception {
template.convertAndSend("foo", "bar");
template.setReceiveTimeout(10_000);
System.out.println(template.receiveAndConvert("foo"));
}
@Bean
public RMQConnectionFactory connectionFactory() {
return new RMQConnectionFactory();
}
}
结果:
bar
关于java - 如何使用 spring boot 和 rabbitmq 启动 hello world js 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45733933/