50.7. 消费者示例
以下是如何接收电话用户要发送到配置的 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 类型 | 描述 |
|---|---|
|
| 传入消息的完整对象表示 |
|
| 消息内容,仅用于文本消息 |