THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Let's look at the necessary modifications to our RouteBuilder
implementation:
Code Block |
---|
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("mina:tcp://localhost:10021") //1
.to("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:provider"); //2
//...and receive messages sent by other JBI endpoints
from("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:consumer")
.to("log:tutorial-jbi")
.convertBodyTo(DOMSource.class)
.to("log:tutorial-domsource")
.convertBodyTo(String.class)
.to("log:tutorial-string");
from("timer://tutorial?fixedRate=true&period=10000")
.setBody(constant("<message>Hello world!</message>"))
.to("mina:tcp://localhost:10021"); // 3
}
}
|
- The only thing we need to know for using our new component in our Camel routes is a new URI format. This line will start a socket listener on port 10021 of our local machine...
- ... and send the incoming message exchanges to our JMS consumer provider endpoint using the
jbi:
URI we learned about on the previous page. Camel will take care of converting the XML String into a valid JBIMessageExchange
once again. - Finally, we also change the final
.to()
of ourtimer:
route to send the message through the socket listener that was started at (1).
Now, we will just tell the user what to expect from the next tutorial page
...