Thanks Mike. So here is my take on things.... No solution just some thoughts...
The scenario we have is a monitor on a specific folder in the O365 Mailbox. This folder is a common staging area for ETL bound messages that come from numerous sources, have different formats, subject lines, attachment names and ultimately different ETL outcomes.
This folder is not the parent INBOX folder but a subfolder of a subfolder for example INBOX/{PROD/PENDING
By doing this we can also have INBOX/DEV/PENDING and simply switch environments PROD versus DEV based on Variables.
Because we have existing scheduled packages looking in this same folder for unique messages based on filters it is possible that messages will come and go quite frequently from this folder.
I know this is over simplified but depending on the polling used by the monitoring agent itself then would it not be possible that the following could occur?
- There is an existing message in the folder and so TotalItemCount = 1 when the monitoring agent first runs. Since this is the first run. Nothing happens.
- Scheduled Job happens to fire and extracts the message and performs ETL.
- Another message arrives - just one.
- The monitoring agent runs again and gets a totalItemCount = 1 (again) and so does not think a new message has arrived
- The new message which is expected to be consumed by the monitor is ignored as the count matched and nothing 'new' is seen.
A following thought I had was if the initial count started at 1 and then at step (3) 2 messages come in. Does the monitor then create 1 or 2 tasks? I am guessing it takes the difference between the start and finish counts which in this case would be 2-1 = 1. If that is the case then does it take the first message, last message or.... what happens if another message comes in whilst it is deciding? My guess it takes the first message and leaves the other alone, resetting the count back to 1 and missing the new message that came in.
Of course, all of this is speculative. But I know that having the mailbox watcher predictable would make a great asset for us. As it stands now, we have a lot of scheduled packages that we have random frequencies on to try and spread the load.
We also, cannot go Big Bang on the watcher alone as we need to keep existing packages running. But having existing scheduled packages affecting the TotalItemCount is probably the root cause of the problem. Plus, it is possible that there may be messages in the folder which do not match the filters and so just keep hanging around until they are manually managed. In this time, we could have messages come and go but the monitor (again depending on polling cycle) may not notice an item count change.
Another approach I thought of was to have the monitor run a single package that then ran a parent package that called all of the existing packages in series expecting one of them to find the data it needs. But that is highly inefficient, and the execution log only shows the result of running the parent and not the child.
The other was that the monitor properties are extended to include the filter logic.
cheers