In flow-1 i.e. in sender, I have two set attachment transformer of type json and text file. I am invoking another application ( receiver) with http requests component. In receiver i am getting this attachment as Inbound attachment payload and not as outbound attachment payload. While sending smtp/email, this attachments gets added and not able to remove it.
I tried by using copy-attachment with wild card name as * and also tried with remove attachment by giving value as message.inboundAttachments['test.json']. I have observed that, all type attachments( set/copy/remove) works for outbound attachment and not for inbound attachments.
1) How do I remove file from inbound attachments? 2) How do get the value of payload in receiver which I have set in sender as 'some data'
code:
sender:
<set-attachment attachmentName="test.json" value="{'Hi':'Hello'}" contentType="text/plain" doc:name="Attachment-JSON"/>
<set-attachment attachmentName="inputdata.json" value="{'k1':'v1','k2':'v2'}" contentType="text/plain" doc:name="Attachment"/>
<set-payload value="#['some data']" doc:name="Set Payload"/>
<http:request config-ref="HTTP_Request_Configuration" path="path2" method="POST" doc:name="HTTP"/>
receiver:
<http:listener config-ref="HTTP_Listener_Configuration" path="path2" allowedMethods="POST" doc:name="HTTP"/>
<foreach collection="#[message.inboundAttachments]" doc:name="For Each">
<logger message="FileName with key: #[key] ==Initial Payload: ====#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</foreach>
<remove-attachment attachmentName="#[message.inboundAttachments'test.json']" doc:name="Attachment"/>
<set-attachment attachmentName="myfile.json" value="#[{'t':'v'}]" contentType="text/plain" doc:name="Attachment-outbound"/>
In the email, i am getting 3 attachments.
Mule version: 3.8