Skip to Content

I recently came across this requirement and thought of sharing it.

Requirement: In one of my project, we had a normal scenario. There was nothing complicated about this, I had to pick up a file from the source location and summarize the data and send it in a mail to a certain distribution list. This interface was working for the US zone and was developed in the PI servers for the US. The same interface had to be done for the Europe zone, but for the Europe, the PI servers were different. To add to this, the email distribution list was the same for both Production systems, US and Europe.

Problem: We did the testing in the Dev servers of both US and Europe and the mail was being generated and received by the recipients in the mail distribution list, we moved it to Quality and then to Production for both the US and Europe servers. However, since the distribution list was the same for all the 3 systems and whenever the interface was triggered from Dev, Quality or Production systems the recipients were not able to distinguish at first glance from which system the mail had been sent, the US systems or Europe systems

Proposed solution I thought by adding the system ID in the mail it would solve the confusion, so I wrote a small UDF to generate the system ID and based on the system ID I would send whether the mail was sent from the US Dev or Test or Production environment or from the Europe. Below is the screenshot of the UDF.

SysID.jpg

This solution was not exactly the way desired, but rather it was required that I had read the hostname from the URL http://Hostname:port/dir/start/index.jsp  and send them the hostname from which PI server the scenario was executed.

Proposed new Solution: Reading the Hostname was not possible with our normal graphical mapping, I could not hardcode it as it had to be retrieved dynamically, so I had to modify the existing UDF to read the Hostname.

Below is the modified UDF where I am reading the Hostname and dynamically sending it to the output, mail distribution list.

/wp-content/uploads/2013/05/hostname_217511.jpg

Below is the code:

AbstractTrace trace = container.getTrace();

String hostname =””;

try

{

                 InetAddress addr = InetAddress.getLocalHost();

               hostname = addr.getHostName();

}

catch(Exception e)

{

                trace.addWarning(e+””);

}

                                return hostname;

Hope this will help, in case you come across a similar requirement 🙂

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply