【发布时间】:2017-08-10 17:48:29
【问题描述】:
刚刚尝试学习 Apache Camel。
我正在尝试阅读 gmail 收件箱中的未读邮件。
我在搜索时得到了代码 sn-p 但无法从中获得成功。
如果有人指出错误,
PollingConsumer pollingConsumer = null;
CamelContext context = new DefaultCamelContext();
Endpoint endpoint = context.getEndpoint("imaps://imap.gmail.com?username=" + mailId + "&password=" + password + "&delete=false&peek=false&unseen=true&consumer.delay=6000&closeFolder=false&disconnect=false");
System.out.println("end point:"+endpoint);
pollingConsumer = endpoint.createPollingConsumer();
System.out.println("polling consumer:"+pollingConsumer);
pollingConsumer.start();
pollingConsumer.getEndpoint().createExchange();
System.out.println("Exchange is created:");
Exchange exchange = pollingConsumer.receive();
System.out.println("pollingConsumer.receive()");
pollingConsumer.receive(); 被阻止,我的邮箱中有未读邮件。
我也试过pollingConsumer.receive(6000);,但它返回null。
我在 Gmail 设置中启用了 IMAP 访问。有什么我想念的吗?
【问题讨论】:
-
你是在代理后面运行这个吗?
-
您的代码对我有用。问题出在骆驼之外。
-
感谢Itsallas 和James 的帮助。我写了解决方案。这是我的错误。
标签: java email apache-camel pooling