141.8. 消费者示例
以下是如何接收电话用户发送到配置的 Bot 的所有消息的基本示例。In Java DSL
from("telegram:bots?authorizationToken=123456789:insertYourAuthorizationTokenHere")
.bean(ProcessorBean.class)
或在 Spring XML 中
<route>
<from uri="telegram:bots?authorizationToken=123456789:insertYourAuthorizationTokenHere"/>
<bean ref="myBean" />
<route>
<bean id="myBean" class="com.example.MyBean"/>
MyBean 是一个将接收消息的简单 bean
public class MyBean {
public void process(String message) {
// or Exchange, or org.apache.camel.component.telegram.model.IncomingMessage (or both)
// do process
}
}
传入消息支持的类型有
| Java 类型 | 描述 |
|---|---|
|
| 传入消息的完整对象表示 |
|
| 消息的内容,仅用于文本消息 |