You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ybrown <yb...@opentext.com> on 2009/06/25 22:11:36 UTC

how to delete email after processing it

Hello,
I am very new to camel and I am trying to read emails via pop3s and delete
them if they had been successfully processed.

if I try to do the this:
from("pop3s://name@gmail.com?password=xxx" +
"&deleteProcessedMessages=true");
I get an exception stating that it is unknown parameter
"deleteProcessedMessages", plus I only want to delete message if I was able
to successfully handle it, not because I simply read it.
I am using camel 1.6.1

Here is a short version of What I have.
    private CamelContext  _camelContext = new DefaultCamelContext();
		
   RouteBuilder builder = new RouteBuilder() {
            public void configure() {

                from("pop3s://name@pop.gmail.com:995?password=xxx" +
&consumer.delay=300000").process(new MailProcessor());
            }
        };
        _camelContext.addRoutes(builder);
        _camelContext.start();


The processor class:

public class MailProcessor implements Processor
{
    public void process(Exchange exchange) throws Exception
    { 
    	MailExchange mExchange = (MailExchange)exchange;
    	//mExchange.getIn().hasAttachments();
    	MailMessage mMessage = mExchange.getIn();
    	Message message = mMessage.getMessage();
    	
    	Address[] address = message.getFrom();
        String subject = message.getSubject();
        Object body = message.getContent();
         .........
     }
}
After processor process the message and only if it was successful, I need to
delete the message.
I cannot figure out how to delete the message, could somebody please help me
out?

Yuliya
-- 
View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24210252.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to delete email after processing it

Posted by ybrown <yb...@opentext.com>.
thank you.
The imap worked fine.


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Ah could be the pop3 protocol that have a limited set of features. Try
> with imap.
> 
> There are some links to some SUN documentation on the mail page (SUN
> JavaMail)
> http://camel.apache.org/mail.html
> 
> 
> On Fri, Jun 26, 2009 at 9:13 PM, ybrown<yb...@opentext.com> wrote:
>>
>> Also, I just turned on the DEBUG on mailComponent
>> and here is what I see
>> Thread: 1 org.apache.camel.component.mail.MailComponent@b81be4 2009-06-26
>> 15:07:48,357 | DEBUG | session=       | user=           |
>> org.apache.camel.component.mail.MailConsumer | Exchange processed, so
>> flagging message as DELETED
>> it seems that message is marked as deleted, but what needs to happen to
>> actually delete it?
>>
>>
>> ybrown wrote:
>>>
>>> you are right, I was actually running it with camel-2-0, I have removed
>>> the jars couple of days ago, but forgot to test it again with this
>>> option.
>>> This time I didn't get an error, but the mail has not been deleted.
>>> I also had a wrong version of java.mail (1.4.2) I just tried with 1.4
>>> and
>>> got the same result.
>>> Can it be that some other jar is of a wrong version or am I still
>>> missing
>>> something.
>>> The deleteProcessedMessages=true is true and Processor is not throwing
>>> an
>>> exception.
>>>
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24225783.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24275330.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to delete email after processing it

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah could be the pop3 protocol that have a limited set of features. Try
with imap.

There are some links to some SUN documentation on the mail page (SUN JavaMail)
http://camel.apache.org/mail.html


On Fri, Jun 26, 2009 at 9:13 PM, ybrown<yb...@opentext.com> wrote:
>
> Also, I just turned on the DEBUG on mailComponent
> and here is what I see
> Thread: 1 org.apache.camel.component.mail.MailComponent@b81be4 2009-06-26
> 15:07:48,357 | DEBUG | session=       | user=           |
> org.apache.camel.component.mail.MailConsumer | Exchange processed, so
> flagging message as DELETED
> it seems that message is marked as deleted, but what needs to happen to
> actually delete it?
>
>
> ybrown wrote:
>>
>> you are right, I was actually running it with camel-2-0, I have removed
>> the jars couple of days ago, but forgot to test it again with this option.
>> This time I didn't get an error, but the mail has not been deleted.
>> I also had a wrong version of java.mail (1.4.2) I just tried with 1.4 and
>> got the same result.
>> Can it be that some other jar is of a wrong version or am I still missing
>> something.
>> The deleteProcessedMessages=true is true and Processor is not throwing an
>> exception.
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24225783.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: how to delete email after processing it

Posted by ybrown <yb...@opentext.com>.
Also, I just turned on the DEBUG on mailComponent
and here is what I see
Thread: 1 org.apache.camel.component.mail.MailComponent@b81be4 2009-06-26
15:07:48,357 | DEBUG | session=       | user=           |
org.apache.camel.component.mail.MailConsumer | Exchange processed, so
flagging message as DELETED
it seems that message is marked as deleted, but what needs to happen to
actually delete it?


ybrown wrote:
> 
> you are right, I was actually running it with camel-2-0, I have removed
> the jars couple of days ago, but forgot to test it again with this option.
> This time I didn't get an error, but the mail has not been deleted.
> I also had a wrong version of java.mail (1.4.2) I just tried with 1.4 and
> got the same result.
> Can it be that some other jar is of a wrong version or am I still missing
> something.
> The deleteProcessedMessages=true is true and Processor is not throwing an
> exception.
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24225783.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to delete email after processing it

Posted by ybrown <yb...@opentext.com>.
you are right, I was actually running it with camel-2-0, I have removed the
jars couple of days ago, but forgot to test it again with this option.
This time I didn't get an error, but the mail has not been deleted.
I also had a wrong version of java.mail (1.4.2) I just tried with 1.4 and
got the same result.
Can it be that some other jar is of a wrong version or am I still missing
something.
The deleteProcessedMessages=true is true and Processor is not throwing an
exception.



Claus Ibsen-2 wrote:
> 
> Hi
> 
> Here is a code snippet from an unit test in camel 1.6.1, from the unit
> test MailFetchSizeTest
> 
> 
> from("pop3://jones@localhost?password=secret&fetchSize=2&consumer.delay=5000"
>                     + "&deleteProcessedMessages=true").to("mock:result");
> 
> camel-mail will only delete the mail message if it was processed
> successfully so in case of an exception it will NOT be deleted.
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24225688.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to delete email after processing it

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Here is a code snippet from an unit test in camel 1.6.1, from the unit
test MailFetchSizeTest


from("pop3://jones@localhost?password=secret&fetchSize=2&consumer.delay=5000"
                    + "&deleteProcessedMessages=true").to("mock:result");

camel-mail will only delete the mail message if it was processed
successfully so in case of an exception it will NOT be deleted.

Could you try again with this option? And if it fails past your
configuration and stacktrace please.

And double check that you use 1.6.1 .jars for all camel-xxx so we are
sure you have the right version in classpath.
In the past people had old versions but thought they where running a
newer version.


On Thu, Jun 25, 2009 at 10:11 PM, ybrown<yb...@opentext.com> wrote:
>
> Hello,
> I am very new to camel and I am trying to read emails via pop3s and delete
> them if they had been successfully processed.
>
> if I try to do the this:
> from("pop3s://name@gmail.com?password=xxx" +
> "&deleteProcessedMessages=true");
> I get an exception stating that it is unknown parameter
> "deleteProcessedMessages", plus I only want to delete message if I was able
> to successfully handle it, not because I simply read it.
> I am using camel 1.6.1
>
> Here is a short version of What I have.
>    private CamelContext  _camelContext = new DefaultCamelContext();
>
>   RouteBuilder builder = new RouteBuilder() {
>            public void configure() {
>
>                from("pop3s://name@pop.gmail.com:995?password=xxx" +
> &consumer.delay=300000").process(new MailProcessor());
>            }
>        };
>        _camelContext.addRoutes(builder);
>        _camelContext.start();
>
>
> The processor class:
>
> public class MailProcessor implements Processor
> {
>    public void process(Exchange exchange) throws Exception
>    {
>        MailExchange mExchange = (MailExchange)exchange;
>        //mExchange.getIn().hasAttachments();
>        MailMessage mMessage = mExchange.getIn();
>        Message message = mMessage.getMessage();
>
>        Address[] address = message.getFrom();
>        String subject = message.getSubject();
>        Object body = message.getContent();
>         .........
>     }
> }
> After processor process the message and only if it was successful, I need to
> delete the message.
> I cannot figure out how to delete the message, could somebody please help me
> out?
>
> Yuliya
> --
> View this message in context: http://www.nabble.com/how-to-delete-email-after-processing-it-tp24210252p24210252.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus