Announcement Announcement Module
Collapse
No announcement yet.
Poller question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Poller question

    Hi,

    I'm using an imap mail receiver with an interval trigger (as the poller) set to 15 seconds. The shouldDeleteMessages property is set to false.

    It works great until there is no message in the INBOX, the poller tries it in every 15 seconds to check mails. But in case there are any mail in the INBOX it's starts to loop continuously. I assume is related with the shouldDeleteMessages variable, as the mails will never disappear.

    Is this a normal behaviour, or did I missed something?

    Thanks & regards,
    Gyuszi

  • #2
    Not 100% clear on what you are saying. Are you saying that it works while there is mail but breaks once there is no more mail?

    The IampMailReceiver attempts to avoiding repeated selection of the same message by looking for messages with the Recent flag set however the specifics of how the Recent flag behaves are a little vague. Quote from spec below.

    " \Recent
    Message is "recently" arrived in this mailbox. This session
    is the first session to have been notified about this
    message; if the session is read-write, subsequent sessions
    will not see \Recent set for this message. This flag can not
    be altered by the client.

    If it is not possible to determine whether or not this
    session is the first session to be notified about a message,
    then that message SHOULD be considered recent.

    If multiple connections have the same mailbox selected
    simultaneously, it is undefined which of these connections
    will see newly-arrived messages with \Recent set and which
    will see it without \Recent set. "

    Comment


    • #3
      Sorry that I was not clear enough.

      Basically I have an inbound-channel-adapter that is configured to poll an imap message source and to "drop" mails into a channel of javax.mail.internet.MimeMessage data type. Than I have a transformer that picks from the channel any mail, do some operations on it, extract some datas, appends a StringBuilder, and than "drops" it into a stream:stdout-channel-adapter. This is how the flow works.
      The imap mail receiver is set to not delete the mails from the server.

      My problem is the poller:
      - if no mails are available in the INBOX I can see in the standard output that there are no logs generated by the transformer, as nothing to transform
      - if I create a new mail in the INBOX I can see in the standard output that the transformer starts to work, but not so frequently as I set in the poller interval (15 seconds in my case) - as I can see there is no delay at all - so the transformer is logging continuously the mail subject for ex.

      I expected to behave in the same way in case 2 like in case 1, I mean in every 15 seconds to see the transformer in work, and to extract the subject from the currently processing message; but instead there is no more polling in the background (but this I cannot confirm 100%).

      My assumption is that probably the mail receiver does not "clears itself" as it expects that the mail will be deleted after receive. And maybe that's why the default implementation of the Pop3MailReceiver is hardcoded to delete mails.

      I hope I made myself more clear. How it should be the normal behaviour of the spring mail integration?

      Thanks,
      Gyuszi

      PS: sorry for any grammatical or literature mistake I made in my post - even in this sentence
      Last edited by szavagyula; Feb 23rd, 2010, 10:57 AM. Reason: Added more explanation

      Comment


      • #4
        Hi Gyuszi

        The behaviour you expect is the same as I would expect. Could you post your xml configuration here. Also what mail server and version of Spring Integration are you using?

        Jonas

        Comment


        • #5
          Hi Jonas,

          Here is the used xml configuration (the standard spring xml header and namespaces are skipped).

          HTML Code:
          <integration:channel id="mimeMessageChannel" datatype="javax.mail.internet.MimeMessage"/>
          
          <stream:stdout-channel-adapter id="stdout" append-newline="true"/>
          
          <integration:transformer input-channel="mimeMessageChannel" output-channel="stdout">
              <bean class="ro.bestseller.integration.mail.test.MailTransformer"/>
          </integration:transformer>
          
          <integration:poller id="poller">
              <integration:interval-trigger interval="15000"/>
          </integration:poller>
          
          <integration:inbound-channel-adapter channel="mimeMessageChannel" ref="mailReceivingMessage">
              <integration:poller ref="poller"/>
          </integration:inbound-channel-adapter>
          
          <bean id="mailReceivingMessage" class="org.springframework.integration.mail.MailReceivingMessageSource">
              <constructor-arg index="0">
                  <bean class="org.springframework.integration.mail.ImapMailReceiver">
                      <constructor-arg index="0" value="imaps://user:pass@somehost:993/INBOX"/>
                      <property name="shouldDeleteMessages" value="false"/>
                  </bean>
              </constructor-arg>
          </bean>
          The MailTransformer class is simple as possible it could be (I wish I could use JAVA highlighter ... so I will use a PHP one):

          PHP Code:
          public class MailTransformer extends AbstractPayloadTransformer<MimeMessageString> {
              @
          Override
              
          protected String transformPayload(MimeMessage messagethrows Exception {
                  
          StringBuilder ret = new StringBuilder(0);
                  
          ret.append("timestamp: ").append(new java.util.Date() + " - " System.currentTimeMillis() + " - " message.getSubject());
                  return 
          ret.toString();
              }

          Before start the application I assure that there is no mail in the INBOX, and also check that the trash is also emptied. After launching the application in the stdout logs there are no entries, and probably after every 15 sec the poller requests for new mails. But after the first mail (with a subject "test"), the stdout is populated very often (not in every 15 seconds). Here is a short output from stdout:

          timestamp: Thu Feb 25 09:36:40 EET 2010 - 1267083400606 - test
          timestamp: Thu Feb 25 09:36:40 EET 2010 - 1267083400813 - test
          timestamp: Thu Feb 25 09:36:41 EET 2010 - 1267083401024 - test
          timestamp: Thu Feb 25 09:36:41 EET 2010 - 1267083401227 - test
          timestamp: Thu Feb 25 09:36:41 EET 2010 - 1267083401579 - test
          timestamp: Thu Feb 25 09:36:41 EET 2010 - 1267083401791 - test
          timestamp: Thu Feb 25 09:36:42 EET 2010 - 1267083402021 - test
          timestamp: Thu Feb 25 09:36:42 EET 2010 - 1267083402227 - test
          timestamp: Thu Feb 25 09:36:42 EET 2010 - 1267083402429 - test
          timestamp: Thu Feb 25 09:36:42 EET 2010 - 1267083402631 - test
          ...
          I'm using spring integration 1.0.3, and at the company is used an imap on a linux distribution (debian I think), but I don't know for sure which one. But, anyhow, I don't think that is related with the mail server, I suppose is something related with the underlying implementation of the mail receiver, or ...

          Regards,
          Gyuszi

          Comment


          • #6
            Could this be related to the fact that the poller takes more than one message per poll?

            You could try to set maxMessagesPerPoll="1" and see if that helps.

            Comment


            • #7
              Hi there,

              If the MailReceivingMessageSource class would return a Message with a list of javax.mail.Message as the payload, it would be a solution to set the maxMessagesPerPoll="1"; as at every poll just one message will be handled that contains in the payload the list of mails.
              But in the described situation this setting does not help at all.

              The solution I think is to re-implement the MailReceivingMessageSource to set into payload the list of messages. If you have a better idea, please share with me.

              Thanks,
              Gyuszi

              Comment


              • #8
                Originally posted by JonasPartner View Post
                The IampMailReceiver attempts to avoiding repeated selection of the same message by looking for messages with the Recent flag set however the specifics of how the Recent flag behaves are a little vague. "
                Hi there,

                We're using the latest available Spring Integration milestone which is 2.0.0.M6 and facing similar issue like this one described by the szavagyula. All messages stored on the server are pulled at the first time an then same messages are pulled again and again in the next calls.

                From my point of view, it seems that "Recent flag" is not proper configured on the MS exchange site or the IMAP adapter simply ignore it. Any other ideas?

                The IMAP adapter has the should-delete-messages parameter present in its configuration:

                Code:
                <mail:imap-idle-channel-adapter <more configuration goes here> should-delete-messages="false" />
                I really appreciate any explanation/help regarding this issue.

                Regards,
                Krzysztof

                Comment


                • #9
                  Hi Krzysztof,

                  Finally I found a solution to avoid continuous pulling. I've created a new MailReceiver class (based on the default implementation), that moves mime messages into a predefined folder, instead of using flags.

                  If this workaround covers your needs I can send it to you the related classes and configurations.

                  Cheers,
                  Gyuszi

                  Comment


                  • #10
                    @ Krzysztof

                    This is a bug. Thank you for pointing this out. You can follow it here: https://jira.springframework.org/browse/INT-1375

                    I'll be committing fix shortly

                    Comment


                    • #11
                      Originally posted by oleg.zhurakousky View Post

                      This is a bug. Thank you for pointing this out. You can follow it here: https://jira.springframework.org/browse/INT-1375

                      I'll be committing fix shortly
                      Hi Oleg,

                      Nice to hear that it will be fixed. Thanks a lot.

                      Regards,
                      Krzysztof

                      Comment


                      • #12
                        Originally posted by oleg.zhurakousky View Post

                        This is a bug. Thank you for pointing this out. You can follow it here: https://jira.springframework.org/browse/INT-1375

                        I'll be committing fix shortly
                        It has been fixed in M7 and it works Thanks!

                        I've got question. How to "unmark" messages on the IMAP server after retrieving them by the <mail:imap-idle-channel-adapter> with should-mark-messages-as-read="true" attribute. What flag is modified on the IMAP server side?

                        Of course changing configuration attribute should-mark-messages-as-read= "false" doesn't work because messages where marked as read in the previous run and won't be retrieved again.

                        Thanks.

                        Regards,
                        Krzysztof

                        Comment


                        • #13
                          Hi SI users,

                          I have checked that and flag that is modified on the Message object is the SEEN flag. However I still don't know how to make messages on the server to be reachable again by the IMAP adapter. Using e-mail client and marking all of them as unread does not work.

                          The easiest workaround is to delete them manually and send them again to mailbox.

                          Any ideas how to revert this SEEN flag on IMAP server?

                          Regards,
                          Krzysztof

                          Comment


                          • #14
                            Could you please explain your use case. IMO 'SEEN' means you saw it, and processed. Yes there is a way to undo that wil Java Mail API, but within the scope of SI flows the scope of what could/should be available is limited since we are not in the business of providing a wrapper over Java Mail API, rather an adapter to send/receive emails.
                            That is why I would be curious about your use case.

                            Comment


                            • #15
                              Hi Oleg,

                              Thanks for your explanation. It's not a regular use case it's rather a test scenario For now I just set this flag to false so the messages are available all the time. I was curious if there is any easy way of changing the seen flag using e-mail client (mark messages as unread does not work).

                              Regards,
                              Krzysztof

                              Comment

                              Working...
                              X