Sending email from parallel jobs

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
esd
Premium Member
Premium Member
Posts: 12
Joined: Fri Dec 14, 2012 9:28 am

Sending email from parallel jobs

Post by esd »

My etl jobs will update a log table based on pending purchase order.
Based on pending list of PO, i need to find manger order and send email request them to approve it.

So its basically a table with list of pending order and manger id(with all details like to,from,subject, body of email details in table) who is responsible for it. How i can send email after reading table. each row in a table needs separate email.


If anyone knows solution, please let me know.
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

You can use the operating system to send emails. Which means you can do it in a parallel job by calling the OS to do it on your behalf.

Otherwise, you can have the parallel job(s) write the email body(s) to a text file(s), and pop out to a post-processing sequence that can use the built in email sending functionality.

I have a crude way to do it:

unyx('mail -s "You Have a Test Failure" ': jp_EmailAddr :' < /dev/null
')

where unyx is an extremely simple c++ program:

#include <cstdlib>
using namespace std;

int syscall(char* cmd)
{
system(cmd);
return 0;
}

(unyx becomes a routine in datastage and is invoked in a transformer).

You can obviously make this more fancy, and embed html or attachments or links and all in your email. And system is not really a good command to use (spawn, etc, have safer versions). But it shows you the approach.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I would prefer a sequence job over a parallel job to effect this requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Post by PaulVL »

Big companies have settings on their Hardware to help prevent them from being spam machines. You might run into a limitation as to how many emails per day per user id you can send from a particular host.

Consult your hardware/os admin teams on that.
esd
Premium Member
Premium Member
Posts: 12
Joined: Fri Dec 14, 2012 9:28 am

Post by esd »

Ray, could you please elaborate how its possible in sequence ? I thought only parallel jobs handle it as i need data from tables to send the emails. Some email content has be derived from table content.
esd
Premium Member
Premium Member
Posts: 12
Joined: Fri Dec 14, 2012 9:28 am

Post by esd »

Is there any way to use DSSendMail from parallel jobs or parallel routine?
ESD
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

You can use the visual basic transformer stage (it looks like, but isnt a transformer) to call a VB routine (a parallel routine) which in turn can call this function. I *think*. I did it with the C code, because that also gave me access to anything that can be done from the command line, which is handy from time to time esp when your datastage account has more power than your own (Including unlimited emails, here) (whistles and walks away).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a server (or parallel) job to read the table and store the result. I prefer a server job, which can store the result in the job's user status area.

In the sequence get the value of the user status area, convert if necessary into a delimited list (using a user variable), and use that list to drive a Start Loop activity. Within the loop, use a Notification activity to send the email.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply