Multiple Task agents sending the same email (sometimes...)

We have emails being send out via data directive on RcvHead so that when something gets received the buyer and/or part manager (UD Field in our company) can get emails notifying them if they have that selected (another UD field(s) to control that). That all works fine except for one weird quirk that I can’t figure out.

Sometimes, (not always) it’s sending duplicate emails. I can see in the email headers that the duplicates are coming from different app servers. We have 3 and when it duplicates they usually get 3. One from each server. I can tell that from the email header. Also, these aren’t the only emails that we are sending that are duplicating, it just seems to be that these are the most often duplicated emails, or at least the ones the users have told us about. I do see some other ones in the logs.



In the log on the back end where you can see times, you can see that they are sent at almost the same time, so don’t think it’s a verification issue like I saw in this post. (although I could be wrong). They also have the same message ID.

So, now I’m at a bit of a loss as to where I need to look next to see what is causing the duplication of the emails being sent. It seems fairly clear that each app server is picking up the email from the email queue and sending another email. But it’s not every email, so there I think that rules out a bug in the code on the data directive, or it would happen every time. Also, if I shut down one of the task agents, I only get as many emails as task agents are running when it’s duplicated (2 instead of 3). So again, being dependent on the number of task agents running should, in my mind, rule out BPM code bugs.

Does anyone else have any previous experience in seeing this problem? Or have an idea on what I should check next? Unfortunately, I know very little about email set-up but I can get answers if I can figure out the right questions to ask.

1 Like

Is there task log to figure out which task agent processed with task?
Looks like concurrency issue in tasks for me.

1 Like

I don’t see the task agent in the mail log, but I can see from the actual emails which app server the email got sent from.

These e-mails are getting sent through code in a BPM, so not a report. I don’t see them in the normal systasklog. Just in the email log.

Any idea on how to confirm or fix this? I’m not opposed to making a support ticket, but I don’t feel like I have enough information to give them to get anywhere yet.

1 Like

It is sent in BPM how? Do you use widgets with async send or just C# for send mail class?

1 Like

C# to send an email. Go through a bunch of code to build the email, then send it like this. It’s being set synchronously because of bad experiences with async processes in the past (which admittedly may or may not be a problem anymore)

No tasks then. They are only used in async sends…

1 Like

Here is more relevant code.

2 Likes

Correct. No tasks. But the task agent somehow picks them up and sends them. Which sounds odd now that I say that.

well I see async on your screeen and it is exactly what I am talking about

    public ISmtpMailer GetMailer(bool async = false)
    {
        return async
            ? this.asyncMailerLazy.Value
            : this.syncMailerLazy.Value;
    }
2 Likes

But if you change it to sync, then transaction may wait for it? What DD is that?

It’s on the RcvHead table. I can try and do a test to and change that if you think it will help? The hard thing is I haven’t been able to recreate the issue, it always works fine in my test systems, so I have to catch it in the wild.

I admit that I am out of my depth here, so I apologize that I don’t really know what I’m talking about when it come to email settings and how it all works.

2 Likes

I mean what DD type? in transaction or Standard.

I am not sure either, but AFAIR async emails are placed into Ice.BpActionQueue and then processed by TA as system task. You can on test system stop TA and look when the update happens.

But still not clear why it depends on app server count not TA tasks count.

1 Like

I am glad that you are open to creating posts and topics though you don’t understand it. I’m sure there are many people who choose not to post because they are uncomfortable with that idea.

I am thankful for people that do what you’re doing cause it helps me learn so much. I look back at some of my earlier posts and posts throughout time and smile at them, cool how much we have all learned.

There is an in transaction to enable the standard where the actual code is being fired.

2 Likes

Same…learned a lot from this place.

We’ve got something a little flaky with automated emails too. Hard to describe. I set up some monthend reports, plus a daily heartbeat-check (a small report) to make sure the System Agent was up and running each morning.

Later on we changed the email methodology and sending address - but I still get the OLD setup mailing to me intermittently - even stranger, it isn’t always at the time (or even the same DAY) as originally scheduled…and that was after removing the original task from the agent.

So I’ve basically let it lie up to this point, chalking it up to being a…

1 Like

wait the title is multiple TA, so it still looks like you process same task several times.

Standard is out of transaction so probably if you set this.GetMailer(), then it will be working fine. But you better test.

1 Like

So just to verify I understand what you are saying,

Just remove the async? So change this:

  var mailer = this.GetMailer(async:true);

to this?

var mailer = this.GetMailer();
1 Like

Yes, because the definition is:

Or you can set it explicitly: GetMailer(async:false)

2 Likes

Got it. I’ll test is in Pilot and see if it breaks anything, then if it seems to keep working, I’ll change it in live and monitor for duplicate email.

Thanks for your help, I’ll let you know what I find out.

3 Likes

I guess my only question is why, on a Data Directive, do you have the condition set in the standard directive enabling the in-transaction directive that actually sends the email (or vice-versa, it’s a little difficult to follow along which is doing what)? Why not just place the condition inside the directive that’s compiling and sending the email and do away with that “enable” widget altogether?

The other issue that you could encounter is if the Header is marked as received, and then unchecked to make a correction or add another line, and then rechecked as received again. That would result in multiple emails getting sent out; and would require your receipt entry personnel to be a little more deliberate when they’re entering receipts - only checking the received checkbox when everything is finalized. That’s a relatively common occurrence with both receipts and shipments (and for those who use it, as to why EDI shipment ASN’s are typically scheduled to process at intervals as opposed to the moment when a transaction occurs).