Problems with executing 2 parallel Aspose processes

Hello Aspose team,

we executing 2 Aspose processes on 2 different servers. both processes uses the following code:
ImapMessageInfoCollection messageInfos = imapClient.ListMessages();
foreach (ImapMessageInfo msgInfo in messageInfos)
{
if (msgInfo.IsRead)
{
log.Debug(“mail=(” + msgInfo.UniqueId + “) is in proccess; read next mail”);
continue;
}
MailMessage mailMsg = imapClient.FetchMessage(msgInfo.UniqueId);
}

The problem is:
- both processes executes the function “imapClient.ListMessages()”
- the first process executes the function “FetchMessage”, so the message flag is set to “IsRead”
- the second process doesnt’ know anything about the “IsRead” flag and it also executes the “FetchMessage”

Is there a possibilty to update the “IMapMessageInfo” after executing the “imapClient.ListMessages()” functionallity?

Best regards
Ralf

Hi Ralf,


Thank you for inquiry.

In this case, both processes get the same message list after calling ListMessages() method at the same time. If one calls FetchMessage(), there is no way for the other process to know the updated status.

Could you please handle this in your application to call the ListMessages() method by only process at a time? We will also try to find out an alternate solution at our end.

Hi Ralf,


Could you please call ImapClient.ListMessage(sequencenumber) method every time for each message? It will always get the latest flags information from the IMAP server. If first process has updated the flag already, the second process will be able to get the latest flag information.

ImapMessageInfoCollection msgInfoColl = client.ListMessages();
Console.WriteLine(“Listing messages…”);
foreach (ImapMessageInfo msgInfo in msgInfoColl)
{
Console.WriteLine("Read: (might be updated by another process) " + msgInfo.IsRead);
// msgInfo might have outdated flags information
// call ListMessage() again to get the latest flag information
ImapMessageInfo updatedMsgInfo = client.ListMessage(msgInfo.SequenceNumber);
Console.WriteLine(updatedMsgInfo.IsRead);
// do some process based on the updated flag information
}

Hello Saqib,

thank you for your answer. But i have also a problem with the "ListMessage" functionallity, so i can't implement your example. Please have a look at my other post:

<A href="https://forum.aspose.com/t/42473</A></P> <P>Best regards,</P> <P>Ralf</P>