Talend Send logs output via email - talend

I have a job in Talend and the part of getting the logs in the email are like this:
tLogCatcher --> main --> tJavaRow
I
onComponentOk --> tSendEmail
My point is that I want to send the output of the logs to an email to get notified.
I use in the tJavaRow:
globalMap.put("errorCode", input_row.message);
and in the tSendEmail:
"Hello,
The input message is" + (String)globalMap.get("errorCode")
However, the (String)globalMap.get("errorCode") part always returns null, while the error message is different.
Do you have any idea why this is the case?
Thanks a lot!

You can just connect tLogCatcher to tSendMail :
In tSendMail you can put this :
"Hello, The input message is" + ((String)globalMap.get("tLogCatcher_1_ERROR_MESSAGE"))
And obviously if there is no error or warning you will get null, so you need to add tWarn or tDie to your job, or just make it erroneous.

Related

QuickFix4J is truncating repeated groups in the FIX messsage

I have a FIX message as a string, and I am creating a message object from this message using QuickFix4J, so that I can send it to the other party.
The DataDictionary that I am using is given to me by the other party.
But when I resolve it with the DD and create the message, many fields especially the ones that are repeating are getting truncated. Basically when a group of field repeats, the final message has only ONE instance of the repeating fields.
This is my original message:
8=FIXT.1.1|9=1288|35=X|34=1163|49=XX|52=20190410-10:27:43|56=XXXXXXXXXXXXXXXXXXXXX|131=XXXXXXXXXXXXXX_2019410_155743|146=1|55=[X/X]|48=58013XXX5|22=1|6360=XXXXXXXX XXXXXXXX|454=1|455=XX58013XXX54|456=4|20200=2|20201=1|20202=6|20203=99.06300000|20204=1111.00|20205=3|20206=XXX2|20201=2|20202=6|20203=0.14400000|20204=2222.00|20205=3|20206=XXX2|460=3|1227=XXXX|29703=XXXX XXXX|167=XXXX|541=20350410|225=20170410|223=0.03500000|106=XXXXXXXXX XXXX XXXXXX XXXX XXX XXXX XXXXX|107=XXX 3.500 3/1/27 X26|873=20170309|54=2|38=188000|64=20190412|15=XXX|126=20190410-10:32:43|60=20190410-10:27:43|663=1|699=9128286X1|761=1|29715=XX9128286X18|29716=4|29717=XXX|29718=0.02625000|29719=20290215|423=6|453=7|448=XXXXXXX1|447=X|452=11|802=1|523=XXXXXXX XXXXXX XX XXX|803=9|448=XXXX|447=X|452=13|448=XXX XXXXXXXXXX 5|447=X|452=13|448=XXXXXX33|447=X|452=17|802=1|523=0355|803=17|448=XXXX|447=X|452=17|448=XXXXXX XXXXXX XXXXXXXXXX (XXX) XXX|447=X|452=17|448=XXXXXXX|447=X|452=13|58=XXXXXX5 (XXXXXXXXXX, XXXXXXX XXXXXX XX XXX) XXXXXXXX XXX XX $100,000 XXX 3.500 03/01/27 X26, XXXXXXXXX XXX 2.625 02/29, XXX XX 2 XXXX XXXXX-XXXXXXX , XXXX XXXX.|5625=2|20117=10155743|5961=XXXXXX|5626=3|20012=1 3|5215=X|5627=XXXXXXXXX|5630=XXXXXXX, XXXX|20120=X2X-XXX-XXXX|21031=X|21032=X|20013=0.3|29724=60|22203=XXXX|29741=000X|29742=1000|10=144|
And this is the message after creating the message object:
8=FIXT.1.1|9=262|35=X|34=656|49=XX|52=20190410-10:27:45.566|56=XXXXXXXXXXXXXXXXXXXXX|131=XXXXXXXXXXXXXX_2019410_155743|146=1|55=[X/X]|48=58013XXX5|22=1|6360=XXXXXXXX XXXXXXXX|454=1|455=XX58013XXX54|456=4|20200=2|20201=2|20202=6|20203=99.06300000|20204=1111.00|20205=3|20206=XXX2|10=111|
This is the code with which I am creating the message:
rawMessage = new Message(newmessage, dataDictionary, false);
Session.sendToTarget(rawMessage, sessionID)
Is there a way I can send the message as is without quickfix4j trying to resolve it and hence truncating fields. Unfortunately I can't share the DD.
I see two issues:
First issue: Your approach is a mistake
rawMessage = new Message(newmessage, dataDictionary, false);
Session.sendToTarget(rawMessage, sessionID)
You can't do that! The sequence numbers, timestamps, etc are not valid anymore!
Are you creating a naive message replayer? (Why do people keep trying to do that?) It's not going to work! FIX messages flows have state that you can't just blindly replay.
If you're creating a test harness, it needs to be smarter than this. Stop what you're doing and reconsider your approach.
Second issue: your DD probably has errors
Truncated repeating groups always means a DataDictionary problem. The DD is not matching the message being parsed. One of the following is surely happening:
the message has put a field in the group that is not in the DD's definition for that group
the message's group has fields out of order (compared to the DD's order)
When parsing a group, the engine will end the group as soon as it sees a field that it does not expect.
The DataDictionary that I am using is given to me by the other party.
Don't trust it! Counterparties make errors with their own docs, because they don't actually use them, or because their internal version are newer than what they've published.
Start parsing your message manually against the DD that they gave you, and I bet you'll find the error.
Thank you Grant for your inputs, finally we figured out that the error was that repeating groups were coming out of order:
datadictionary.setCheckUnorderedGroupFields(false);
solved it.

Is the problem about Datastage Message Handler?

I have a problem about message handler on IBM Datastage. I am trying to suppress this message: ""no more conversion warnings will be issued" . I added to Message Handler at project level. But when I run the job, it gives the warning message again.
Thank you in advance.
Message handler only work for Parallel jobs - what is your job type?
Have you added the message handler in the administrator client?
If yes follow these steps:
In the job log check the second entry „Attached Message Handlers:“ and check if the message handler is active.
Open the message with the warning and check the message ID and compare it to the one of your message handler - the need tobe identical

Can you use part of the email subject to populate the To field in the Email Outbound Point in mule?

I have an Email to Email flow that needs to send specific senders depending on the email subject. I was using #[message.inboundProperties.subject.substring(40,3) to get the value but its ending up in error. I'm not sure which function to use to get the value I need from the subject since the order number is also there. Any tips? All my needed values are on the subject line at the moment.
Also, Can I use this value to generate an email body for the message?
To: [Sender]
Hi [Sender]
Your order no [Order] was successfully imported
Thanks Mule
The first question that comes to mind is from where are you getting the Subject ? Is it a Fixed statement ?
What you can do is other way round. You can store the [Order] and [Sender] in flow variables and then you can construct a Subject line and email body out of it.
For example let you store your [Order] in a flow variable as follows:-
<set-variable variableName="Order" value="#[message.inboundProperties.'order']" doc:name="Variable"/>
and [Sender] in another flow variable :-
<set-variable variableName="Sender" value="someone#example.com" doc:name="Variable"/>
Then you can send [Order] and [Sender] in subject line :-
Hi #[flowVars.Sender.split('#')[0]] your order number #[flowVars.Order] is ready
And in email body you can write as following :-
Hi #[flowVars.Sender.split('#')[0]]
Your order no#[flowVars.Order] was successfully imported
Thanks Mule
Please note I have used flowVars.Sender.split('#')[0] to get the sender name from email address ...
reference :- How can I extract the user name from an email address using javascript?

How to get the latest email using CFIMAP

I am using the below code block in CF9 to get all the mail data,
<cfimap
action="GETHEADERONLY"
name="LOCAL.checkEmail"
secure="true"
folder="Inbox"
server="#ImportAquireMailServer#"
username="#ImportAquireUsername#"
password="#ImportAquirePassword#" />
This query object provides the information about all the mails present in inbox. While doing so it takes a lot of time and also times out frequently.
Is there any way to get the latest mail only, so that it will not provide the information about all the mails and will also not run into time out situation?
Please help.
you may need to update the read messages to "read" like:
<cfimap action="MarkRead" connection = "Conn" messagenumber="#getHeaders.messagenumber#">
after the message id done with work.
so you can query the latest messages as:
<cfquery dbtype="query" name="getMails">
select * from getHeaders
where seen=<cfqueryparam value="no" cfsqltype="cf_sql_varchar">
</cfquery>also you can filter with received date
you can refer http://shemy-coldfusion.blogspot.in/2013/03/coldfusion-code-to-get-multiple-mail.html

Mule 3.5.0 - How to move a file to an 'Failed' directory and send email when an exception is thrown during processing

I have Mule flow that is reading a file (csv) from an input directory and inserting records into a database. I'd like to know how to move this file to a 'failed' directory and send a notification email should an error occur in the flow. Currently my flow is as follows:
<flow name="mainFlow" doc:name="mainFlow" processingStrategy="synchronous">
<file:inbound-endpoint path="src/test/input" moveToDirectory="src/test/backup" responseTimeout="10000" doc:name="input-file" connector-ref="inputFile"/>
<READS FILE INTO DATABASE>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<file:outbound-endpoint path="src/test/error" doc:name="error-output-file"/>
</catch-exception-strategy>
</flow>
Ideally, when the file is moved to the 'failed' directory, it has the same name as the original file with 'error' appended to beginning. I've not yet attempted the email notification as I'm unsure as to how to approach this. Any help/guidance would be greatly appreciated, thanks in advance!
The original file name is available in message properties, so you can use outputPattern="error#[header:originalFilename]" in the file outbound. If your method for reading the file content into database loses the original file content, you could set a variable to hold the content right after you have read the file, and then set the variable as payload before writing the into the error directory in the exception handler.
UPDATE: For the email part, you have several options: basically you just set your email message content as payload and then send it with Mule SMTP outbound, or some email service like Mailgun that offers a simple REST API. It is really quite simple if you just have a suitable email provider.