You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by takidean <ta...@hotmail.fr> on 2013/03/12 23:25:58 UTC
from server to oracle
hi
i de developped some code in which i have to receive data from a server over
sockets then send it into an oracle data base i need some help ,i'm new in
apache camel someone give me his opinion about this:
public class Action {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
CamelContext cnt = new DefaultCamelContext();
ConnectionFactory connectionFactory =new
ActiveMQConnectionFactory("vm://localhost");
cnt.addComponent("jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
cnt.addRoutes(new MyRouteBuilder());
cnt.start();
Thread.sleep(1000);
cnt.stop();
}
/********route builder***********/
public class MyRouteBuilder extends RouteBuilder{
/**
* @param args
*/
@Override
public void configure() throws Exception {
from("mina:tcp://--adress--?textline=true")
.to("jms:queue:incomingorders")
.to("bean:orderToSql")
.to("jdbc:oracle--wboard--");
}
}
/************ordertoOrale**********/
public class orderToOracle {
public String toSql(@XPath("order/@name") String name,
@XPath("order/@amount") int amount,
@XPath("order/@customer") String customer) {
StringBuilder sb = new StringBuilder();
sb.append("insert into incoming_orders ");
sb.append("(part_name, quantity, customer) values (");
sb.append("'").append(name).append("', ");
sb.append("'").append(amount).append("', ");
sb.append("'").append(customer).append("') ");
return sb.toString();
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/from-server-to-oracle-tp5729049.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: from server to oracle
Posted by takidean <ta...@hotmail.fr>.
thank you for responding
--
View this message in context: http://camel.465427.n5.nabble.com/from-server-to-oracle-tp5729049p5729201.html
Sent from the Camel - Users mailing list archive at Nabble.com.
AW: from server to oracle
Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
Camel in Action chapter 7.4 gives an example with Apache CXF.
from("cxf:bean:incomingOrders").to("seda:incomingOrders").transform(constant
("OK"))
(SpringDSL in the book ;)
The book contains much more about setting up all things.
Also the Loan Broker example from the EIP pattern book is implemented in
Camel. And one version with WS.
http://camel.apache.org/loan-broker-example.html
Jan
> -----Ursprüngliche Nachricht-----
> Von: takidean [mailto:takidean1@hotmail.fr]
> Gesendet: Donnerstag, 14. März 2013 01:48
> An: users@camel.apache.org
> Betreff: Re: from server to oracle
>
> im new in apache camel , i read camel in action but i have yet many
> questions , i'm pressed because i have to achieve my project in which
> there are many routes and endpoints .i search for help , to receive
> messages from an external web service what endpoint should i use to
> connect it.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/from-
> server-to-oracle-tp5729049p5729150.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: from server to oracle
Posted by takidean <ta...@hotmail.fr>.
im new in apache camel , i read camel in action but i have yet many questions
, i'm pressed because i have to achieve my project in which there are many
routes and endpoints .i search for help , to receive messages from an
external web service what endpoint should i use to connect it.
--
View this message in context: http://camel.465427.n5.nabble.com/from-server-to-oracle-tp5729049p5729150.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: from server to oracle
Posted by Willem jiang <wi...@gmail.com>.
What's the error did you get?
As you using using the ActiveMQ VM transport, you need to put the JMS client and the camel route into the same JVM.
--
Willem Jiang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On Wednesday, March 13, 2013 at 6:25 AM, takidean wrote:
> hi
> i de developped some code in which i have to receive data from a server over
> sockets then send it into an oracle data base i need some help ,i'm new in
> apache camel someone give me his opinion about this:
> public class Action {
>
> /**
> * @param args
> * @throws Exception
> */
> public static void main(String[] args) throws Exception {
>
> CamelContext cnt = new DefaultCamelContext();
> ConnectionFactory connectionFactory =new
> ActiveMQConnectionFactory("vm://localhost");
>
> cnt.addComponent("jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
> cnt.addRoutes(new MyRouteBuilder());
>
>
> cnt.start();
> Thread.sleep(1000);
> cnt.stop();
> }
>
> /********route builder***********/
> public class MyRouteBuilder extends RouteBuilder{
>
> /**
> * @param args
> */
>
> @Override
> public void configure() throws Exception {
>
> from("mina:tcp://--adress--?textline=true")
> .to("jms:queue:incomingorders")
> .to("bean:orderToSql")
> .to("jdbc:oracle--wboard--");
>
> }
>
>
> }
> /************ordertoOrale**********/
> public class orderToOracle {
> public String toSql(@XPath("order/@name") String name,
> @XPath("order/@amount") int amount,
> @XPath("order/@customer") String customer) {
> StringBuilder sb = new StringBuilder();
> sb.append("insert into incoming_orders ");
> sb.append("(part_name, quantity, customer) values (");
> sb.append("'").append(name).append("', ");
> sb.append("'").append(amount).append("', ");
> sb.append("'").append(customer).append("') ");
> return sb.toString();
> }
> }
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/from-server-to-oracle-tp5729049.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
Re: from server to oracle
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
When you send to the JMS queue then you may want to send that either as
- InOnly (aka fire and forget)
- InOut (request reply over JMS)
See the following EIPs about that
http://camel.apache.org/event-message.html
http://camel.apache.org/request-reply.html
So if you want fire and forget then you should do
.to(ExchangePattern.InOnly, "jms:queue:incomingorders")
On Tue, Mar 12, 2013 at 11:25 PM, takidean <ta...@hotmail.fr> wrote:
> hi
> i de developped some code in which i have to receive data from a server over
> sockets then send it into an oracle data base i need some help ,i'm new in
> apache camel someone give me his opinion about this:
> public class Action {
>
> /**
> * @param args
> * @throws Exception
> */
> public static void main(String[] args) throws Exception {
>
> CamelContext cnt = new DefaultCamelContext();
> ConnectionFactory connectionFactory =new
> ActiveMQConnectionFactory("vm://localhost");
>
> cnt.addComponent("jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
> cnt.addRoutes(new MyRouteBuilder());
>
>
> cnt.start();
> Thread.sleep(1000);
> cnt.stop();
> }
>
> /********route builder***********/
> public class MyRouteBuilder extends RouteBuilder{
>
> /**
> * @param args
> */
>
> @Override
> public void configure() throws Exception {
>
> from("mina:tcp://--adress--?textline=true")
> .to("jms:queue:incomingorders")
> .to("bean:orderToSql")
> .to("jdbc:oracle--wboard--");
>
> }
>
>
> }
> /************ordertoOrale**********/
> public class orderToOracle {
> public String toSql(@XPath("order/@name") String name,
> @XPath("order/@amount") int amount,
> @XPath("order/@customer") String customer) {
> StringBuilder sb = new StringBuilder();
> sb.append("insert into incoming_orders ");
> sb.append("(part_name, quantity, customer) values (");
> sb.append("'").append(name).append("', ");
> sb.append("'").append(amount).append("', ");
> sb.append("'").append(customer).append("') ");
> return sb.toString();
> }
> }
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/from-server-to-oracle-tp5729049.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen