Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible to route all of request to another server directly? For example route all of this project specific rest endpoint localhost:8080/get-something to another project endpoint like this: someIp:8081/get-something2 . something like this:

from("localhost:8080/get-something")
.to("someIp:8081/get-something2")

or this:

rest()
            .path("/get-something")
            .get()
                .route()
.to("someIp:8081/get-something2")

I've tried too many ways but I cant!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

I think you want to use a WireTap, just going by your description.

So you’ll do something like

’’’ from("localhost:8080/get-something") . wiretap(“direct:endpoint1”) // will receive exchange . wiretap(“direct:endpoint2”) // will receive exchange .to(ACTUAL_DESTINATION); // will receive exchange … ;

’’’

Then

’’’ from(“direct:endpoint1”) .to(MY_SERVER1);

from(“direct:endpoint2”) .to(MY_SERVER2); ’’’

Something to note though, is that these are completely separate messages (think a carbon copy) only if you specify a custom processor via the onPrepareRef property


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...