[resolved] tRestRequest endpoint with hostname variable

One Star

[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 ?

Accepted Solutions
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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.

All Replies
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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"
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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

Re: [resolved] tRestRequest endpoint with hostname variable

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.
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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?
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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.
Employee

Re: [resolved] tRestRequest endpoint with hostname variable

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
One Star

Re: [resolved] tRestRequest endpoint with hostname variable

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
Employee

Re: [resolved] tRestRequest endpoint with hostname variable

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