Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20907

came-mail - In Poll Enrich EIP, get email attachments are empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Information Provided
    • 3.18.0
    • 4.x
    • came-core
    • None
    • Unknown

    Description

      Let's say I need to wait for an event notification and then pull an attachments email like this:

      Camel version 3.18.x

      from("servlet://foo?servletName=MyServlet")
      .loopDoWhile().simple("${exchangeProperty.CamelBatchComplete} == null || ${exchangeProperty.CamelBatchComplete} == false")
      .pollEnrich("imaps://{{mail.server}}?session=#oAuthSession&closeFolder=false&peek=true&folderName={{mail.sub.folder}}&sendEmptyMessageWhenIdle=true")
      .process(exchange -> {
      AttachmentMessage attachmentMessage = exchange.getIn(AttachmentMessage.class);
      // Here attachments is null
      Map<String, DataHandler> attachments = attachmentMessage.getAttachments();
      })
      .end();

       

      Same code, works fine in Camel 3.14.x but doesn't work in Camel 3.18.x.

      After debugging, it was found that in Camel 3.16.x, the implementation of DefaultAttachmentMessage.java was upgraded.

      The key point is the CamelAttachmentObjects property in the ExchangeProperty, which is placed in the Exchange property in version 3.14.x, and in the ExtendedExchange property in version 3.16.x, which results in the loss of the CamelAttachmentObjects property between different Exchange.

      Details can be found in the link below line 274:

      https://github.com/apache/camel/commit/0125a133a11cbdff57d459634bac276c10963387

      I tried a solution as follows:

      Camel version 3.18.x

      from("servlet://foo?servletName=MyServlet")
      .loopDoWhile().simple("${exchangeProperty.CamelBatchComplete} == null || ${exchangeProperty.CamelBatchComplete} == false")
      .pollEnrich("imaps://{{mail.server}}?session=#oAuthSession&closeFolder=false&peek=true&folderName={{mail.sub.folder}}&sendEmptyMessageWhenIdle=true",
      ((oldExchange, newExchange) -> {
      // Deliver the attachment to the oldExchange
      oldExchange.setIn(newExchange.getIn(AttachmentMessage.class));
      return oldExchange;
      }))
      .process(exchange -> {
      AttachmentMessage attachmentMessage = exchange.getIn(AttachmentMessage.class);
      Map<String, DataHandler> attachments = attachmentMessage.getAttachments();
      })
      .end(); 

      The above can solve the problem of not being able to get attachments, but there will be other properties missing.

      Can you help with this? If information is missing, please do not hesitate to contact.

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              kangjian kangjian
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: