Вам нужно экранировать "@" с "%40" для имени пользователя и пароля и указать --port=993
для gmail. Кроме того, можно не работать с настройками по умолчанию, поскольку GMail требует SSL для imap, и это также необходимо настроить.
Итак, я бы предложил следующее (в основном, создание нового исходного модуля):
- Перейдите в
spring-xd-1.0.0.M6\xd\modules\source
и сделайте копию папки mail
и назовите эту копию gmail
- Перейдите к
spring-xd-1.0.0.M6\xd\modules\source\gmail\config
и переименуйте mail.properties
и mail.xml
в gmail.properties
и gmail.xml
соответственно.
- Внутри
gmail.xml
замените все на:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<channel id="output" />
<int-mail:mail-to-string-transformer
charset="${charset}" input-channel="transform" output-channel="output" />
<beans:beans profile="use-polling">
<int-mail:inbound-channel-adapter
store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}"
channel="transform" should-mark-messages-as-read="${markAsRead}"
should-delete-messages="${delete}" java-mail-properties="javaMailProperties">
<poller fixed-delay="${fixedDelay}" time-unit="SECONDS">
<advice-chain>
<beans:bean
class="org.springframework.xd.dirt.module.support.ThreadContextClassLoaderSetterAdvice" />
</advice-chain>
</poller>
</int-mail:inbound-channel-adapter>
</beans:beans>
<beans:beans profile="use-idle">
<int-mail:imap-idle-channel-adapter
store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}"
channel="transform" auto-startup="true" mail-filter-expression="${expression}"
should-mark-messages-as-read="${markAsRead}"
should-delete-messages="${delete}" java-mail-properties="javaMailProperties">
</int-mail:imap-idle-channel-adapter>
</beans:beans>
<beans:beans profile="default">
<util:properties id="javaMailProperties">
<beans:prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</beans:prop>
<beans:prop key="mail.imap.socketFactory.fallback">false</beans:prop>
<beans:prop key="mail.store.protocol">imaps</beans:prop>
<beans:prop key="mail.debug">false</beans:prop>
</util:properties>
</beans:beans>
</beans:beans>
4. В оболочке XD теперь вы будете использовать что-то вроде следующего для создания своего потока:
stream create --name myGmailStream --definition "gmail --host=imap.gmail.com --username=yyyyyyyy12%40gmail.com --password=my_password --port=993 | file --dir=/tmp/gmailData" --deploy
Здесь обратите внимание на следующее:
- Я добавил
--port=993
- имя пользователя содержит "%40" вместо "@"
- определение потока начинается с
"gmail
- если ваш пароль содержит "@", вам также необходимо заменить его на "%40"
То, что я сделал выше, это, по сути, создание нового пользовательского модуля (источника), что довольно просто (более подробную информацию об этом вы можете найти в документация). Отдельный узел XD или оболочку XD даже не нужно перезапускать. Попробуйте и дайте мне знать, как это происходит.
person
Andrei Stefan
schedule
23.05.2014