Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello !
I'm able to implement APIs jobs, but now I want to better understand routes.
Here is a simple test API job : sending the response message "ping"
What I need : I am not sure I understood routes as they really are. I see it like a meta way to manage jobs or other message exchanges, but I think I might be wrong.
My goal here is to use a route to print a message in Talend console when the API URL is called. In the future I would like to be able to implement a load balancer, but for now I have to do simple things to understand how routes work.
I created this route :
How I do : to correct me if it's the proper way
The API job shown above is already running and working via my browser.
I run the route.
I get an error : already bind.....
So, is it possible to do what I want ?
OK, you are nearly there. The thing you have not done considered is that routes are always on. Therefore they need something to trigger the processing. You can do this in several ways, but I will demonstrate this by triggering the route with a different URL.
Notice the two cMessagingEndpoints. cMessagingEndpoint_1 is used to provide the trigger endpoint. This is shown below....
To trigger this, you simply need to call http://localhost:8088/hello with a web browser.
The cMessagingEndpoint_2 is where your service is called. I am simply calling a demo service from the net. My component looks like this....
Pay attention to the "?bridgeEndpoint=true" at the end of my api call. You need to add this to yours. It essentially tells your route that this api is being "bridged". Essentially an api to call an api.
The cProcessor component is simply used to print the result of the bridged api call. This is seen below...
I hope this helps
Up !
OK, you are nearly there. The thing you have not done considered is that routes are always on. Therefore they need something to trigger the processing. You can do this in several ways, but I will demonstrate this by triggering the route with a different URL.
Notice the two cMessagingEndpoints. cMessagingEndpoint_1 is used to provide the trigger endpoint. This is shown below....
To trigger this, you simply need to call http://localhost:8088/hello with a web browser.
The cMessagingEndpoint_2 is where your service is called. I am simply calling a demo service from the net. My component looks like this....
Pay attention to the "?bridgeEndpoint=true" at the end of my api call. You need to add this to yours. It essentially tells your route that this api is being "bridged". Essentially an api to call an api.
The cProcessor component is simply used to print the result of the bridged api call. This is seen below...
I hope this helps
Hello, I'm sorry for the late answer.
Unfortunatelly I get the same error :
java.net.BindException: Address already in use: bind org.apache.camel.RuntimeCamelException: java.net.BindException: Address already in use: bind at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) at org.apache.camel.main.Main.doStart(Main.java:139) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.main.MainSupport.run(MainSupport.java:170) at tutorial_project.routetest_0_1.RouteTest.run(RouteTest.java:214) at tutorial_project.routetest_0_1.RouteTest.runJobInTOS(RouteTest.java:329) at tutorial_project.routetest_0_1.RouteTest.main(RouteTest.java:299) Caused by: java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:401) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:345) at org.apache.camel.http.common.HttpCommonEndpoint.connect(HttpCommonEndpoint.java:175) at org.apache.camel.http.common.HttpConsumer.doStart(HttpConsumer.java:54) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3705) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:4023) at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3958) at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3878) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3642) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3494) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) ... 6 more Job RouteTest terminé à 17:53 02/09/2019. [Code sortie=1]
This works with you API URL (dummy API) tough..
May this error be because I'm on the same computer....?
I also ran the API job first, and then ran the route, then went on the hello URL but error with my API...
You need to start the service first in the Studio, then switch to the Route and start that.
If that doesn't work can you share a screenshot of your service and your route (with configuration of your cMessagingEndpoints) and I will take a look.
Hello, here is my configuration :
My REST API test job : the response is just "ping"
It works and I let the job running.
Now my route where I applied what you advised :
Here I set the bridge :
However, when I run the route, I get this error :
java.net.BindException: Address already in use: bind org.apache.camel.RuntimeCamelException: java.net.BindException: Address already in use: bind at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) at org.apache.camel.main.Main.doStart(Main.java:139) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.main.MainSupport.run(MainSupport.java:170) at tutorial_project.routetest_0_1.RouteTest.run(RouteTest.java:216) at tutorial_project.routetest_0_1.RouteTest.runJobInTOS(RouteTest.java:331) at tutorial_project.routetest_0_1.RouteTest.main(RouteTest.java:301) Caused by: java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.Net.bind(Unknown Source) at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:401) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:345) at org.apache.camel.http.common.HttpCommonEndpoint.connect(HttpCommonEndpoint.java:175) at org.apache.camel.http.common.HttpConsumer.doStart(HttpConsumer.java:54) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3705) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:4023) at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3958) at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3878) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3642) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3494) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) ... 6 more
Ah, I forgot to mention this. You will need to use a different port for your route. Start your web service using port 8088 and your route with port 8089 and try that.
This worked ! Now I can keep discovering Routes and C components !
Thanks a lot rhall_2_0 !!!!