2

I want to enable camel load balancer for multiple datasource. Any one please let me how to enable multiple datasource in camel jdbc endpoint. Thanks in advance!!

Here is my code. Creating multiple datasource in defaultcamelcontext.

        SimpleRegistry simpleregistry = new SimpleRegistry();
        Map<String, Object> ds = new HashMap<String, Object>();
        ds.put("dataSource", mydataSource);
        ds.put("dataSource1", mydataSource1);
        simpleregistry.putAll(ds);

        Camel camel = CamelExtension.get(system);
        DefaultCamelContext defaultCamelContext = camel.context();
        defaultCamelContext.setRegistry(simpleregistry);

My route builder pointing to multiple datasource:

    from("direct:checkUser").setBody(simple("${body}"))
            .loadBalance()
            .failover()
            .to("jdbc:dataSource?resetAutoCommit=false&outputType=SelectList","jdbc:dataSource1?resetAutoCommit=false&outputType=SelectList");

My requirement is if datasource is down my request need to redirect/pick automatically to datasource1. Please let me how to achieve it.

mpromonet
  • 11,326
  • 43
  • 62
  • 91
asr
  • 51
  • 4
  • Why my question degraded to -1. If anyone need more explanation I can. – asr Feb 23 '15 at 07:23
  • If you hover the mouse over the down arrow and read the tooltip, you can see why people may vote your question down. – Claus Ibsen Feb 23 '15 at 08:46
  • You need to provide more information showing you have done some attempts yourself to solve the problem. For example, show your camel routes where the datasource is used, in particular the endpoints. – vikingsteve Feb 23 '15 at 09:00
  • Camel experts please help. This is urgent requirement for us. – asr Feb 24 '15 at 06:49

1 Answers1

1

Separate the to, so they are individual

from("direct:checkUser").setBody(simple("${body}"))
       .loadBalance().failover()
            .to("jdbc:dataSource?resetAutoCommit=false&outputType=SelectList")
            .to("jdbc:dataSource1?resetAutoCommit=false&outputType=SelectList");
Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65