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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tRestRequest endpoint with hostname variable

We have a tRestRequest component deployed and working nicely behind load-balancer using endpoint name like:
"h t t p ://beta-conn-talend1:8090/services"
Now we need to extend to multiple hosts and do not want to hard code the hostname in the component.
How do we best achieve this?  Context variable ?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Maybe you could also check the .cfg file of your job located at "container/etc/YOURJOBNAME.cfg"
It should have the name of the context you defined in the Studio.

View solution in original post

9 Replies
Anonymous
Not applicable
Author

Solved.  Added tjava component:
String thishostname = InetAddress.getLocalHost().getHostName();
System.out.println(thishostname);
context.hostname = thishostname;
advanced settings: import java.net.InetAddress;
Then changed endpoint to "h t t p : / / " + context.hostname + ":8090/services"
Anonymous
Not applicable
Author

I thought this was solved because it ran correctly from ESB Studio, but when deployed it fails to substitute the context.
Any suggestions ?
Anonymous
Not applicable
Author

mmeasel,
In the studio, you can declare a property file from File -> Edit project properties -> job settings -> implicit context load.
There you can define a path, the path should be shipped with the job/route.
You still need to have the correct path defined and property file needs to be present at that path on your server.
Hope this helps.
Anonymous
Not applicable
Author

Morgan, thank you for your response but the problem is not with the context being loaded.
The problem is that the runtime behavior is different from the studio behavior.  
My laptop (studio):
Starting job echo_test at 12:41 27/08/2014.
connecting to socket on port 3938
connected
MLaptop
: org.apache.cxf.endpoint.ServerImpl - Setting the server's publish address to be h t t p : / / MLaptop:8090/services
: org.eclipse.jetty.server.Server - jetty-8.1.14.v20131031
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@MLaptop:8090
Server (ESB runtime):
17:26:25,608 | INFO  | Refresh Packages | g.apache.cxf.endpoint.ServerImpl   84
| 120 - org.apache.cxf.cxf-api - 2.7.11 | Setting the server's publish address to be h t t p : / / " + context.hostname + ":8090/services
Anonymous
Not applicable
Author

If I understand right, you want to get the name of your host where the job runs and your context.hostname doesn't get filled?
Anonymous
Not applicable
Author

Maybe you could also check the .cfg file of your job located at "container/etc/YOURJOBNAME.cfg"
It should have the name of the context you defined in the Studio.
Anonymous
Not applicable
Author

Hi,
I'd like to add that as far as I recall one can have a relative address only set in the studio, it should be set to a correct absolute URI when deployed into the container
Cheers, Sergey
Anonymous
Not applicable
Author

sberyozkin,
You can also have a relative address in the runtime.
Karaf will deploy the job on the ports defined in container/etc/org.ops4j.pax.web.cfg
Anonymous
Not applicable
Author

Yes, this is what I actually meant,
Cheers, Sergey