Hi,
I'm trying to figure out why my imap client works in a JUnit but not on Tomcat.
The difference is that in the junit the client receives the messages and those fitered out are logged properly. On Tomcat the client is connected to the mailbox, the emails are seen but not processed.
This is the config:
This is the client:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:int-mail="http://www.springframework.org/schema/integration/mail" xmlns:int="http://www.springframework.org/schema/integration" xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <int-mail:imap-idle-channel-adapter id="customAdapter" store-uri="imaps://${imap.user}:${imap.password}@${imap.server.name}:${imap.server.port}/${imap.server.mailbox}" channel="receiveChannel" auto-startup="true" should-delete-messages="false" should-mark-messages-as-read="true" java-mail-properties="javaMailProperties" mail-filter-expression="subject == '${my.response.email.subject}'" /> <int:channel id="receiveChannel"> <int:interceptors> <int:wire-tap channel="logger" /> </int:interceptors> </int:channel> <int:logging-channel-adapter id="logger" level="DEBUG" /> <int:service-activator input-channel="receiveChannel" ref="imapClientService" method="receive" /> <util:properties id="javaMailProperties"> <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop> <prop key="mail.imap.socketFactory.fallback">false</prop> <prop key="mail.store.protocol">imaps</prop> <prop key="mail.debug">true</prop> </util:properties> </beans>
The configuration is imported in Tomcat along other working Spring configurations.Code:import javax.mail.internet.MimeMessage; import org.springframework.stereotype.Service; @Service public class MyClientService { public void receive(MimeMessage mimeMessage) { // ... } }
This is a snippet of logs of JUnit test, where the messages are processed but ignored because of the filter :
This is a snippet of Tomcat logs, where the new message can be seen but is not processed:Code:DEBUG IMAP: IMAPProtocol noop A5 NOOP A5 OK NOOP completed. * 1 RECENT * 264 EXISTS DONE A5 OK IDLE completed. A6 FETCH 264 (BODYSTRUCTURE) * 264 FETCH (BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-1" "format" "flowed") NIL NIL "7bit" 0 0 NIL NIL NIL NIL)) A6 OK FETCH completed. DEBUG IMAP: IMAPProtocol noop A6 NOOP A6 OK NOOP completed. A7 LIST "" INBOX * LIST (\Marked \HasNoChildren) "/" INBOX A7 OK LIST completed. 24 Aug 2012 16:06:29,887 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver INFO - attempting to receive mail from folder [INBOX] org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:229) 24 Aug 2012 16:06:29,888 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch. org.springframework.integration.mail.ImapMailReceiver.compileSearchTerms(ImapMailReceiver.java:180) A8 SEARCH NOT (ANSWERED) NOT (DELETED) NOT (SEEN) NOT (FLAGGED) ALL * SEARCH 263 264 A8 OK SEARCH completed. 24 Aug 2012 16:06:30,118 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - found 2 new messages org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:238) A9 FETCH 263:264 (ENVELOPE INTERNALDATE RFC822.SIZE FLAGS BODYSTRUCTURE) * 263 FETCH (ENVELOPE ("Fri, 24 Aug 2012 07:48:17 -0700" "test 12" (("My Name" NIL "my.name" "mydomain.com")) NIL NIL ((NIL NIL "my.recipient" "mydomain.com")) NIL NIL NIL "<50379431.1040904@mydomain.com>") INTERNALDATE "24-Aug-2012 15:48:24 +0100" RFC822.SIZE 694 FLAGS () BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-1" "format" "flowed") NIL NIL "7bit" 0 0 NIL NIL NIL NIL)) * 264 FETCH (ENVELOPE ("Fri, 24 Aug 2012 08:06:28 -0700" "test 111" (("My Name" NIL "my.name" "mydomain.com")) NIL NIL ((NIL NIL "my.recipient" "mydomain.com")) NIL NIL NIL "<50379874.10001@mydomain.com>") INTERNALDATE "24-Aug-2012 16:06:35 +0100" RFC822.SIZE 694 FLAGS (\Recent) BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-1" "format" "flowed") NIL NIL "7bit" 0 0 NIL NIL NIL NIL)) A9 OK FETCH completed. 24 Aug 2012 16:06:30,388 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - Recieved 2 messages org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:244) 24 Aug 2012 16:06:30,389 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - USER flags are not supported by this mail server. Flagging message with system flag org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:266) A10 STORE 263 +FLAGS (\Flagged) * 263 FETCH (FLAGS (\Flagged)) A10 OK STORE completed. A11 FETCH 263 (BODY.PEEK[HEADER.FIELDS (Newsgroups)]) * 263 FETCH (BODY[HEADER.FIELDS (Newsgroups)] {2} ) A11 OK FETCH completed. 24 Aug 2012 16:06:30,943 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - Fetched email with subject 'test 12' will be discarded by the matching filter and will not be flagged as SEEN. org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:279) 24 Aug 2012 16:06:30,943 [task-scheduler-1]: org.springframework.integration.mail.ImapMailReceiver DEBUG - USER flags are not supported by this mail server. Flagging message with system flag org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:266) A12 STORE 264 +FLAGS (\Flagged) * 264 FETCH (FLAGS (\Flagged \Recent)) A12 OK STORE completed.
Code:DEBUG IMAP: IMAPProtocol noop A3 NOOP A3 OK NOOP completed. DEBUG IMAP: IMAPProtocol noop A4 NOOP A4 OK NOOP completed. * 1 RECENT * 265 EXISTS DEBUG IMAP: IMAPProtocol noop A5 NOOP A5 OK NOOP completed.
Where is the mistake? Please help me! TIA
Rob


Reply With Quote
