Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Passing Header values to a SubJob in a route

I am trying to figure out the best way to pass header values from a Job to a SubJob within a route.
Here is how my current route looks (Screenshot attached - Hopefully):
Main Job:
Poll for a content file -->
Set header values for fileName, fileSize, DBConnection, etc -->
Call a stored proc to insert the file -->
Store the result as a header value to use later (result is a UID) -->
Move the file to a different directory -->
Create the body of my JMS message which is just the location of the file to Checksum -->
Call a JMS Queue to do a MD5Checksum on the file.
SubJob:
Receive JMS Message with File Location and Name -->
Checksum the file -->
Set the checksum result as a header value -->
Call a stored procedure to add the checksum to the file record in the DB
When I call the subjob I lose all of the Header Values that I set in the main job. I could change my JMS message to contain all of the data I need, but I would like to pass all the header values in the JMS message instead. Is there a way to do this?
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I figured out my issue. In my route I was doing a setBody to create a checksum request. When I created that new message I lost all of the headers from my original message. I changed the set body so that the headers were propagated to the new message and everything worked.
In my setBody (cProcessor) I had this:
//get fileName header
String fileName = exchange.getIn().getHeader("fileName", String.class);
System.out.println("fileName = " + fileName);
//set body to full file path with header value
exchange.getOut().setBody(context.ProjectRoot + context.WorkingDir + fileName);
and changed it to this:
//get fileName header
String fileName = exchange.getIn().getHeader("fileName", String.class);
System.out.println("fileName = " + fileName);
//set body to full file path with header value
exchange.getOut().setBody(context.ProjectRoot + context.WorkingDir + fileName);
//reset headers so you dont lose them
exchange.getOut().setHeaders(exchange.getIn().getHeaders());

View solution in original post

1 Reply
Anonymous
Not applicable
Author

I figured out my issue. In my route I was doing a setBody to create a checksum request. When I created that new message I lost all of the headers from my original message. I changed the set body so that the headers were propagated to the new message and everything worked.
In my setBody (cProcessor) I had this:
//get fileName header
String fileName = exchange.getIn().getHeader("fileName", String.class);
System.out.println("fileName = " + fileName);
//set body to full file path with header value
exchange.getOut().setBody(context.ProjectRoot + context.WorkingDir + fileName);
and changed it to this:
//get fileName header
String fileName = exchange.getIn().getHeader("fileName", String.class);
System.out.println("fileName = " + fileName);
//set body to full file path with header value
exchange.getOut().setBody(context.ProjectRoot + context.WorkingDir + fileName);
//reset headers so you dont lose them
exchange.getOut().setHeaders(exchange.getIn().getHeaders());