kangjian created CAMEL-20907:
--------------------------------

             Summary: came-mail:In Poll Enrich EIP, get email attachments are 
empty
                 Key: CAMEL-20907
                 URL: https://issues.apache.org/jira/browse/CAMEL-20907
             Project: Camel
          Issue Type: Bug
          Components: came-core
    Affects Versions: 3.18.0
            Reporter: kangjian


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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to