Apache Camel http to http routing (Is it possible?)

14,994

You need to bridge the endpoint.

from("jetty:http://0.0.0.0:8080/myapp/myservice")
.to("http4://www.google.com?bridgeEndpoint=true&throwExceptionOnFailure=false");
Share:
14,994

Related videos on Youtube

kazanaki
Author by

kazanaki

I am a Software Engineer who loves clean and compact code, simple solutions and modular distributed systems. I hate feature creep, over-engineering, XML gluttony and monolithic systems. I have a soft spot for code quality and build systems. I have also authored a book about the Spock testing framework https://www.manning.com/books/java-testing-with-spock My professional webpage - http://codepipes.com

Updated on May 28, 2022

Comments

  • kazanaki
    kazanaki almost 2 years

    I am starting now with Camel. I have seen the http4 component for http clients and the jetty component for http servers.

    I have seen several examples that use one or the other. I would like to know if it is possible to combine them together.

    Example

    from("jetty:http://0.0.0.0:8080/myapp/myservice")
    .to("http4://www.google.com");
    

    This would make camel a simple http based router/proxy. Web browsers would hit the camel URL and instead get google. (Google is just an example, I have a real POST based service that I want to use)

    Is this route possible? Should I research Camel or do I need a different software framework for this? In the future I would also need to add transformations/filters in between.

    I have tried it and got a nullpointer exception

    [qtp757856402-14] SendProcessor       DEBUG >>>> Endpoint[http4://www.google.com] Exchange[Message: [Body is instance of java.io.InputStream]]
    [qtp757856402-14] DefaultErrorHandler DEBUG Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. On delivery attempt: 0 caught: java.lang.NullPointerException
    [qtp757856402-14] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
    java.lang.NullPointerException
    
  • kazanaki
    kazanaki about 13 years
    I am impressed! I got an answer from the guru himself! Thank you! Please keep monitoring stackoveflow for camel questions...
  • Claus Ibsen
    Claus Ibsen about 13 years
    I'm just nursing the community. That's important as well. And on the way you learn what end users does with Camel.
  • Claus Ibsen
    Claus Ibsen over 11 years
    We have added a page about this solution at: camel.apache.org/…
  • Claus Ibsen
    Claus Ibsen over 11 years
    Just a heads-up we are adding url rewriting support in Camel 2.11, which allows you more control of the url mappings when bridging. This page will have more details (at this time of writing still work in progress) - camel.apache.org/urlrewrite
  • kazanaki
    kazanaki over 11 years
    Thanks! This is really great!