Thank You for reply.
I did two things but not getting any result.
1. Created Simple UI with JButton and Created
class MailPoller public class MailPoller extends javax.swing.SwingWorker{
public Object doInBackground() throws Exception{
try {
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("imaps://imap.gmail.com?
[email protected]&password=mypassword"
+
"&delete=false&unseen=true&consumer.delay=60000").to("log:newmail");
System.out.println("Configured");
}
});
camelContext.start();
} catch (Exception ex) {
Logger.getLogger(MailPoller.class.getName()).log(Level.SEVERE,
null, ex);
}
}
}
2 .
class MainExample {
.......
.......
.......
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("imaps://[email protected]&password=mypassword"
+
"&delete=false&unseen=true&consumer.delay=60000").process(new
Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Invoked timer at " + new Date());
}
});
}
}
.......
}
Please guide me.
On 11/18/11, Claus Ibsen <[email protected]> wrote:
> Hi
>
> You need to keep your main thread running. The start() on CamelContext
> is a non blocking operation.
>
> See this FAQ
> http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html
>
>
> On Thu, Nov 17, 2011 at 7:35 PM, Ketan Barapatre
> <[email protected]> wrote:
>> Hello Bilgin
>>
>> I read SSL and Enable POP and IMAP in my gmail account.
>> I have written code for polling mail but not getting any result. It
>> must be my mistake somewhere.
>>
>> Please help me to correct my code. I want to read mails to complete my
>> project.
>>
>> public class MailPoller {
>>
>> public static void main(String[] args) {
>> try {
>> CamelContext myCamelContext = new DefaultCamelContext();
>> RouteBuilder routeBuilder = new RouteBuilder(myCamelContext) {
>>
>> @Override
>> public void configure() throws Exception {
>>
>> from("imaps://[email protected]&password=mypassword"
>> +
>> "&delete=false&unseen=true").to("log:newmail");
>> }
>> };
>>
>> myCamelContext.start();
>>
>> } catch (Exception ex) {
>> Logger.getLogger(MailPoller.class.getName()).log(Level.SEVERE,
>> null, ex);
>> }
>> }
>> }
>>
>> On 11/11/11, Bilgin Ibryam <[email protected]> wrote:
>>> Hi Ketan,
>>>
>>> Please read (again) the SSL section of mail component documentation from
>>> Camel website and check the example there. Then you have to enable pop
>>> for
>>> your gmail account in the settings.
>>>
>>> Finally the rout should look like something like this:
>>>
>>> pop3s://pop.gmail.com?username=....
>>>
>>> or
>>>
>>> imaps://imap.gmail.com?username=...
>>>
>>> notice the S in the schemas
>>>
>>>
>>> HTH
>>> Bilgin
>>>
>>>
>>> On Thu, Nov 10, 2011 at 3:22 PM, Ketan Barapatre
>>> <[email protected]>wrote:
>>>
>>>> Hello All,
>>>>
>>>> To poll the mail. I tried following code
>>>>
>>>> CamelContext myCamelContext = new DefaultCamelContext();
>>>> //final String url = "imap://
>>>> [email protected]&password=mypassword";
>>>> //final String url = "smtp://
>>>> smtp.gmail.com:465?password=mypassword&[email protected]";
>>>> final String url = "pop3://[email protected]?password=mypassword";
>>>> Endpoint endpoint = myCamelContext.getEndpoint(url);
>>>> System.out.println(" endpoint " + endpoint);
>>>>
>>>> RouteBuilder routeBuilder = new RouteBuilder(myCamelContext) {
>>>> @Override
>>>> public void configure() throws Exception {
>>>> from(url).process(new MyMailProcessor());
>>>> }
>>>> };
>>>>
>>>> myCamelContext.addRoutes(routeBuilder);
>>>> myCamelContext.start();
>>>> MyMailProcessor.java
>>>>
>>>> public class MyMailProcessor implements Processor {
>>>>
>>>> public void process(Exchange exchng) throws Exception {
>>>> System.out.println("" + exchng);
>>>> }
>>>> }
>>>>
>>>> As i understand when message is read from my Inbox *process* method of
>>>> MyMailProcessor executes.
>>>>
>>>> Please correct me if i'm wrong. I am very new to this.
>>>>
>>>> I am using camel-mail v2.8.2 and NetBeans 7 on Win XP.
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>>
>> Regards
>> Ketan Barapatre
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [email protected]
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
--
Regards
Ketan Barapatre