Mailbox Add Service adds same message repeatedly inside a loop

Technote (troubleshooting)


Mailbox Add Service adds same message repeatedly inside a loop


After collecting all the files using a FSA or from MQ, these collected messages when tried to put in a mailbox, same message gets added by Mailbox Add Service which is used in a loop.


The cause is both PrimaryDocument and Document ID existing in the ProcessData.If both PrimaryDocument and Document ID are present in the ProcessData, PrimaryDocument will be ignored and Document ID will be considered by the Mailbox Add Service.

Diagnosing the problem

There are no issues when Mailbox Add Service gets executed once and not in a loop.

When there is a loop and a DocumentID is already present in the ProcessData, and, Mailbox Add Service gets executed for the second time the issue can occur.

Resolving the problem

You can add all the messages in the mailbox using Mailbox Add Service inside the loop. You can use For Each Document Service to loop through all the files collected from a FSA. However it is important to use Release Service also inside the loop to remove the nodes - "DocumentId" and "MessageName". If these nodes are not removed, content in the first document will be put in all the messages added to the Mailbox and all the name of the messages added will also be the name of the first document.

Here is a sample Business Process for reference :
<process name="mbadd_sample_ForEach">
<rule name="DocFound">
<condition>DOC.DONE = 1</condition>

<sequence name="Pull Sequence">
<operation name="File System Adapter">
<participant name="EDIInboundFSAdapter"/>
<output message="FileSystemInputMessage">
<assign to="Action">FS_COLLECT</assign>
<assign to="bootstrap">false</assign>
<assign to="collectMultiple">true</assign>
<assign to="sortBy">FS_FILENAME</assign>
<assign to="deleteAfterCollect">false</assign>
<assign to="." from="*"></assign>
<input message="inmsg">
<assign to="." from="*"></assign>

<sequence name="DocLoop">
<operation name="For Each Document">
<participant name="ForEachDocument"/>
<output message="ForEachDocumentTypeInputMessage">
<assign to="." from="*"></assign>
<assign to="ITERATOR_NAME">DOC</assign>
<input message="inmsg">
<assign to="." from="*"></assign>

<choice name="Choice Start">
<case ref="DocFound" negative="true" activity="AddMailbox"/>

<sequence name="AddMailbox">

<operation name="Mailbox Add Service">
<participant name="MailboxAdd"/>
<output message="MailboxAddServiceTypeInputMessage">
<assign to="." from="*"></assign>
<assign to="MailboxPath">/EDIInboundCollection</assign>
<input message="inmsg">
<assign to="." from="*"></assign>

<operation name="release">
<participant name="ReleaseService"/>
<output message="Xout">
<assign to="TARGET">DocumentId | MessageName</assign>
<input message="Xin"/>

<repeat name="Get Next Doc" ref="DocLoop"/>

Rate this page:

(0 users)Average rating

Add comments

Document information

More support for:

Sterling B2B Integrator

Software version:


Operating system(s):


Reference #:


Modified date:


Translate my page

Machine Translation

Content navigation