spring_reference/IV. Spring Boot features/30.1.5. Receiving a message.md

14 lines
593 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 30.1.5. 接收消息
当JMS基础设施能够使用时任何bean都能够被@JmsListener注解以创建一个监听者端点。如果没有定义JmsListenerContainerFactory一个默认的将会被自动配置。下面的组件在someQueue目标上创建一个监听者端点。
```java
@Component
public class MyBean {
@JmsListener(destination = "someQueue")
public void processMessage(String content) {
// ...
}
}
```
具体查看[@EnableJms javadoc](http://docs.spring.io/spring/docs/4.1.4.RELEASE/javadoc-api/org/springframework/jms/annotation/EnableJms.html)。