0
我想用駱駝的google-mail component從我的賬戶中獲取最新的郵件。具體來說,我將history
端點前綴與列表端點一起使用。我的路線是這樣的如何在apache駱駝的google郵件組件中爲消費者設置所需的參數
<route id="parseNewMails">
<from uri="g-mail://history/list?userId=me&consumer.delay=10000"/>
<!-- <setHeader headerName="CamelGoogleMail.startHistoryId">
<constant>2938321</constant>
</setHeader> -->
<to uri="file://output1"/>
</route>
的Google Mail Api規定,我可以使用參數,如startHistoryId
,labelId
等等來控制output.But,我如何通過他們的URI?
<from uri="g-mail://history/list?userId=me&CamelGoogleMail.startHistoryId=291234&consumer.delay=10000"/>
OR
<from uri="g-mail://history/list?userId=me&startHistoryId=291234&consumer.delay=10000"/>
不起作用。它拋出這個錯誤:
Failed to resolve endpoint: g-mail://history/list?CamelGoogleMail.startHistoryId=2938321&consumer.delay=10000&userId=me due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{CamelGoogleMail.startHistoryId=2938321}]
編輯 :: 我有所需的依賴增加
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-google-mail</artifactId>
<version>2.17.2</version>
</dependency>
和配置
<bean id="g-mail" class="org.apache.camel.component.google.mail.GoogleMailComponent">
<property name="configuration">
<bean class="org.apache.camel.component.google.mail.GoogleMailConfiguration">
<property name="accessToken" value="xxx" />
<property name="applicationName" value="Simple Sample" />
<property name="clientId" value="xxx" />
<property name="clientSecret" value="xxx" />
<property name="refreshToken" value="xxx" />
<property name="scopes" value="https://www.googleapis.com/auth/gmail.readonly,https://www.googleapis.com/auth/gmail.modify,https://www.googleapis.com/auth/gmail.labels" />
<!-- <property name="p12FileName" value="" />
<property name="user" value="" /> -->
</bean>
</property>
</bean>
注意組件的歷史前綴列表端點工作。它只是我不能指定startHistoryId參數。
我添加了依賴項。我使用g-mail的原因是因爲這是我用來配置google-mail組件的bean的id。我已經更新了原來的問題並添加了相關的代碼片段。 –
請在camel header中設置startHistoryId的值。它應該工作。 「任何URI選項都可以在帶有CamelGoogleMail。前綴的生產者端點的消息頭中提供。」 – gnanagurus
我也更新了答案 – gnanagurus