343.7. 消费者示例
以下是如何接收 telegram 用户将发送到配置的 Bot 的所有信息的基本示例。在 Java DSL 中
from("telegram:bots/123456789:insertYourAuthorizationTokenHere")
.bean(ProcessorBean.class)或在 Spring XML 中
<route>
<from uri="telegram:bots/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 类型 | 描述 |
|---|---|
|
| 传入消息的完整对象表示 |
|
| 消息的内容,仅用于文本信息 |