[mule-user] how to handle bad from address in mails using pop connector?

30 views
Skip to first unread message

Craig Hamilton

unread,
Jan 29, 2007, 1:11:27 AM1/29/07
to us...@mule.codehaus.org
Hi,

I am monitoring an email address with the pop connector.  However, a subset of the emails have a problem with the from header in the email, which causes the following error.

I was wondering what the best way to deal with this is.  I would like to either route them over to a manual processing email box, or ideally if I could get in there and fix up the from address so the email goes through the rest of the system that would be great.  (The from really isn't that important for what I am doing with the emails)

I have been looking at the exception strategies, and I am just not getting my head around how I should deal with this.

Any ideas would be much appreciated.

craig


******************************
**************************************************
Exception stack is:
1. Missing '<' (javax.mail.internet.AddressException)
  javax.mail.internet.InternetAddress:656 ( http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/internet/AddressException.html)
2. Failed to receive event over: MuleEndpoint{connector=org.mule.providers.email.Pop3Connector@1c8f59c, endpointUri= pop3://user:pa...@domain.com?checkFrequency=12000&, transformer=null, name='bouncePopConnector', type='receiver', properties={=, checkFrequency=12000}, transactionConfig=Transaction{factory=null, action=NONE, timeout=30000}, filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=null, initialState=started, createConnector=0, remoteSync=null, remoteSyncTimeout=null, endpointEncoding=null} (timeout=-1) ( org.mule.umo.provider.ReceiveException)
  org.mule.providers.email.Pop3MessageReceiver:200 ( http://mule.codehaus.org/docs/apidocs/org/mule/umo/provider/ReceiveException.html )
********************************************************************************
Root Exception stack trace:
javax.mail.internet.AddressException: Missing '<' in string ``Mail Administrator <Postmaster@<PostmasterDomain>>'' at position 49
    at javax.mail.internet.InternetAddress.parse(InternetAddress.java:656)
    at javax.mail.internet.InternetAddress.parseHeader(InternetAddress.java:554)
    at javax.mail.internet.MimeMessage.getAddressHeader (MimeMessage.java:658)
    at javax.mail.internet.MimeMessage.getFrom(MimeMessage.java:321)
    at org.mule.providers.email.Pop3MessageReceiver.storeMessage(Pop3MessageReceiver.java:300)
    at org.mule.providers.email.Pop3MessageReceiver.messagesAdded (Pop3MessageReceiver.java:170)
    at org.mule.providers.email.Pop3MessageReceiver.poll(Pop3MessageReceiver.java:342)
    at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:71)
    at org.mule.impl.work.WorkerContext.run (WorkerContext.java:301)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)

********************************************************************************

Andrew Perepelytsya

unread,
Jan 29, 2007, 8:18:57 PM1/29/07
to us...@mule.codehaus.org
Craig,

You can put a custom exception strategy on the pop3 connector for starters. Alternatively, you can specify one on the descriptor and deal with the error on a more fine-grained level. Anyway, you'll want to understand what you want to do with the error.

If everything you want to do is just provide some defaults for the from field in case it's corrupted, you may get away with as little effort as subclassing the Pop3MessageReceiver and overriding a couple of methods (it already handles the missing from address, you can add your parse exception handling there). Granted the required method is private, so a bit copy-pasting on your side is required. I've made it protected in trunk, however.

HTH,
Andrew

Craig Hamilton

unread,
Jan 29, 2007, 10:56:08 PM1/29/07
to us...@mule.codehaus.org
Andrew,

Thanks for the help.

I have this for my connector, and the exception still goes through the default:

    <connector name="popConnector" className="org.mule.providers.email.Pop3sConnector ">
       <properties>
       <property name="checkFrequency" value="12000"/>
        <map name="serviceOverrides">
            <property name="inbound.transformer " value="org.mule.transformers.NoActionTransformer"/>
        </map>
        </properties>
        <exception-strategy className="com.spintop.mule.exceptionhandling.PopExceptionHandler "/>
    </connector>

If I was to subclass the Pop3MessageReceiver, where would I configure it to be used instead of the standard Pop3MessageReceiver?

thanks,
craig

Andrew Perepelytsya

unread,
Jan 30, 2007, 9:34:46 AM1/30/07
to us...@mule.codehaus.org
Craig,

Use the serviceOverrides map on the connector. Check http://muledocs.org/General+Transport+Configuration

It's strange your exception strategy doesn't kick in. Are you overriding the correct methods?

Craig Hamilton

unread,
Jan 31, 2007, 12:05:14 PM1/31/07
to us...@mule.codehaus.org
I have the following, but it does not seem to use my custom receiver.

I checked and the service overrides map is being set, but it instantiates the standard receiver.

Am I overriding this incorrectly?

thanks,
craig



<connector name="popConnector" className="org.mule.providers.email.Pop3sConnector">
       <properties>
       <property name="checkFrequency" value="12000"/>
        <map name="serviceOverrides">
            <property name="inbound.transformer" value="org.mule.transformers.NoActionTransformer"/>
            <property name="connector" value=" com.spintop.mule.providers.email.PopBadAddressReceiver"/>
        </map>
    </properties>
    </connector>

Holger Hoffstätte

unread,
Jan 31, 2007, 12:17:40 PM1/31/07
to us...@mule.codehaus.org
Craig Hamilton wrote:
> I have the following, but it does not seem to use my custom receiver.

<property


name="connector"
value="com.spintop.mule.providers.email.PopBadAddressReceiver"/>

Take a closer look. ;)

-h


---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Andrew Perepelytsya

unread,
Jan 31, 2007, 12:24:42 PM1/31/07
to us...@mule.codehaus.org
The doc has message.receiver as the property you have to override.

Andrew

Craig Hamilton

unread,
Feb 1, 2007, 12:31:44 AM2/1/07
to us...@mule.codehaus.org
It is working now.  The big problem I was having was I was defining a pop3s connector in my connector section, and then the end point was using a pop3 service url.  So obviously the overrides weren't applying to the endpoint's connector.  Too subtle of a difference for this newbie to detect.

I feel I am grasping it all better now.  Mule is really nice.

As you mentioned regarding the pop connector, because of the non-public methods I basically cut and paste the existing one and made my own with a couple lines changed.  I look forward to getting the next version which will have some hooks and i will refactor.

Thanks a lot for all your help, much appreciated.

craig

Tony Lu

unread,
Feb 1, 2007, 4:08:56 AM2/1/07
to us...@mule.codehaus.org

Hi All,

 

I am a little confused about how to continue with this issue.

Requirements:

1>     Mule monitoring files for some file directory

2>     When there is new file in the monitored directory,  it need to read content of the file and create new file with different content

3>     Output to different new directory for new file

1st issue,

It seems I should do item2 and item3 in MyFileReceiver. processFile(). Because I found file default receiver has done almost of the business

Of file operations such as delete source file, move file etc in processFile() method. But if I do it like this, then how about UMOComponent ‘MyComponent’, it seems

Nothing to do for him.   And how can I get public variable map which is created in initialize() method in MyComponent?

2nd issue:

If I do it in MyComponent, it seems it’s not what I wanted because before I do item2 in dobusiness() method, source file has been moved to new directory.

=======================Example File ============================

, public class MyComponent implements Initialisable {

         Logger logger = Logger.getLogger(MyComponent.class.getName());

         Map map ;

 

         public void initialise() {

                   map = new HashMap();

                   logger.info("************************Do Initialise**************************");

         }

 

         public void dobusiness(String message) throws UMOException {

                   logger.info("============= Doing =========== Business Logic =========== ");

         }

}

 

public class MyFileReceiver extends PollingMessageReceiver

{

………

    public synchronized void processFile(final File sourceFile) throws UMOException

    {

        

        logger.info("doing process file !!!..........!!!");

}

……

}

 

Please help !!!!!!!!!!!!!!!!!!

 

Ben Hood

unread,
Feb 1, 2007, 4:20:01 AM2/1/07
to us...@mule.codehaus.org
Tony,
 
Have you read the wiki docs?
 
 
Cheers,
 
Ben


From: Tony Lu [mailto:tony...@gmail.com]
Sent: 01 February 2007 09:09
To: us...@mule.codehaus.org
Subject: [mule-user] Need help for file connector customization ......

This message has been checked for all email viruses by MessageLabs.


*****************************************************

You can find us at www.voca.com

*****************************************************
This communication is confidential and intended for
the exclusive use of the addressee only. You should
not disclose its contents to any other person.
If you are not the intended recipient please notify
the sender named above immediately.

Registered in England, No 1023742,
Registered Office: Voca Limited
Drake House, Three Rivers Court,
Homestead Road, Rickmansworth,
Hertfordshire, WD3 1FX

This message has been checked for all email viruses by MessageLabs.

kenneth.w...@telenet.be

unread,
Feb 1, 2007, 5:07:52 AM2/1/07
to us...@mule.codehaus.org
If I remember correctly, you want to monitor a folder and all its subfolders, right?
So if you've configured to listen on c:\a, you want all files that are put in c:\a and in all subfolders of c:\a.
What you want to do is copy paste all the code from the default FileMessageReceiver and modify the listFiles method. This method is responsible of reading and returning the files that are available in the folder.
Hope this helps.

Tony Lu

unread,
Feb 1, 2007, 5:23:37 AM2/1/07
to us...@mule.codehaus.org
Thanks for your reply,

One purpose is to monitor a folder and all its subfolders.
Now I know where and how to create new message receiver about it.
But it's not only for file copy and paste.

I need to read content of source file and create new file to new directory.
The business logic is complicated and it needs some other public variables
from UMOComponent.

I am not sure if it's OK to compose business logic in new message receiver
class.
And don't know how to get public variables in UMOComponent.


-----邮件原件-----
发件人: kenneth.w...@pandora.be [mailto:kenneth.w...@telenet.be]

发送时间: 2007年2月1日 18:08
收件人: us...@mule.codehaus.org
主题: Re: [mule-user] Need help for file connector customization ......

kenneth.w...@telenet.be

unread,
Feb 1, 2007, 5:30:33 AM2/1/07
to us...@mule.codehaus.org
>One purpose is to monitor a folder and all its subfolders.
>Now I know where and how to create new message receiver about it.
>But it's not only for file copy and paste.
Good!

>I need to read content of source file and create new file to new directory.
>The business logic is complicated and it needs some other public variables
>from UMOComponent.
>
>I am not sure if it's OK to compose business logic in new message receiver
>class.

It's not ok to execute business logic in the FileMessageReceiver. The connectors should only be used to connect your Mule to external system. That's their sole purpose. Please read the Architecture Guide on this matter.
I think you want to read files from a folder and its subfolders and then maybe aggregate this. If this is what you want, please read: http://mule.mulesource.org/wiki/display/MULE/Message+Routers#MessageRouters-Aggregator
The aggregating process is something you will have to write, but its not that difficult to do.

Reply all
Reply to author
Forward
0 new messages