camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kraythe ." <kray...@gmail.com>
Subject Re: Help apache camel jdbc + active
Date Mon, 16 Dec 2013 17:46:04 GMT
As said above. Use quartz or an AMQ event to trigger it.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Mon, Dec 16, 2013 at 4:54 AM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:

> As mentioned in the Camel docs for the JDBC component: This component can
> only be used to define producer endpoints, which means that you cannot use
> the JDBC component in a from() statement.
>
> So if you want to poll message from a database you shouldn't use the JDBC
> component but instead use either the SQL component (
> http://camel.apache.org/sql-component.html), JPA component (
> http://camel.apache.org/jpa) or MyBatis component (
> http://camel.apache.org/mybatis) instead. These do support the polling
> consumer EIP.
>
>
> On Mon, Dec 16, 2013 at 10:48 AM, RJILI Youssef <rjiliyoussef@gmail.com
> >wrote:
>
> > I'm new in apache camel and i have a problem about the filling of the
> > activemq.
> > I want to get the values from DB and filled it into activemq.
> > My activemq is started:
> >
> > My code :
> >
> >
> > private void fillActiveMq() throws Exception{
> > JndiRegistry registry = new JndiRegistry(new JndiContext());
> > CamelContext camelCtxt = new DefaultCamelContext(registry);
> > MysqlDataSource datasource = getDataSource();
> > JdbcEndpoint endpoint = getJDBCEndPoint(datasource, camelCtxt);
> >
> > registry.bind("bulksms", datasource);
> >
> >
> >
> camelCtxt.addComponent("activemq",ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
> > camelCtxt.addEndpoint("jdbc:bulksms", endpoint);
> >
> >         ProducerTemplate pT= camelCtxt.createProducerTemplate();
> >         pT.sendBody("jdbc:bulksms" , "select message from message");
> >
> > camelCtxt.addRoutes(new RouteBuilder() {
> >
> >  @Override
> > public void configure() throws Exception {
> > interceptSendToEndpoint("jdbc:*").throwException(new
> > ConnectException("Cannot connect"));
> > from("jdbc:bulksms").setBody(constant("select message from
> > message")).to("activemq:queue:messages");
> > }
> > });
> >   camelCtxt.start();
> > Thread.sleep(1000);
> >
> > camelCtxt.stop();
> > }
> >  private  MysqlDataSource getDataSource() {
> > MysqlDataSource datasource = new MysqlDataSource();
> > datasource.setUser("root");
> > datasource.setPassword("root");
> > datasource.setDatabaseName("bulksms");
> > datasource.setPortNumber(3306);
> > datasource.setServerName("127.0.0.1");
> > return datasource;
> > }
> >
> > private  JdbcEndpoint getJDBCEndPoint(MysqlDataSource datasource,
> > CamelContext camelCtxt) {
> >
> > JdbcEndpoint endpoint = new JdbcEndpoint();
> > endpoint.setDataSource(datasource);
> > endpoint.setCamelContext(camelCtxt);
> > return endpoint;
> > }
> >
> > I have this exception :
> > Exception in thread "main" java.lang.UnsupportedOperationException: Not
> > supported
> > at
> >
> >
> org.apache.camel.component.jdbc.JdbcEndpoint.createConsumer(JdbcEndpoint.java:59)
> > at
> >
> >
> org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
> > at
> >
> org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
> > at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
> > at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> > at
> >
> >
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
> > at
> > com.apachecamel.ManageQueueFromDB.fillActiveMq(ManageQueueFromDB.java:76)
> > at com.apachecamel.ManageQueueFromDB.main(ManageQueueFromDB.java:43)
> >
> > I only used java DSL code, Any Help please
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message