Hi

Your questions is a bit confusing. Its better to ask a single question
instead of 3 at the same time, with a bunch of code etc.

For the spring app context being null, that is not a Camel issue, but
a Spring issue as its spring that does the IoC for that.

You seem to use Spring's @Component which you would need to use the
Spring way to tell Spring that it should do a component context scan.
There is some special <context-scan> etc. you need to set in your
spring <beans> to instruct Spring about that. Google and check the
spring docs.



On Fri, Oct 12, 2012 at 4:18 AM, zuff <bhtan1...@live.com> wrote:
> Dear All,
>
>   [Had reference :
> http://camel.465427.n5.nabble.com/How-to-programatically-add-remove-camel-route-td469238.html
> without much success]
>
>    I need some helping in generating a dynamic route. Please point out any
> other places that I have done wrong.
> Some background info:
> a.  An Icefaces projects packaged into a EAR and deployed on a 10.3 Weblogic
> b.  A standalone camel application.
>
> A
>
> Project_Main
> +src
> ++org/learning
> +++PublisherBean
> +++StandardRequestBean
> +++AdHocRequestBean
>
> Project_Web
> +WEB-INF
> ++applicationContext.xml
> ++web.xml
>
> some code extract of StandardRequestBean
>
> @Component
> public class StandardRequestBean extends PublisherBean implements
> ApplcationContextAware
> {
>      protected ApplicationContext applicationContext;
>      protected SpringCamelContext  camelContext;
>      protected String dynamicAddressKey = UUID.randomUUID().toString();
>      protecte String dynamicAddress = "activemq:temp:topic:" +
> dynamicAddressKey;
>      protected IPublisherUtil publisherUtil;
>      protected RouteBuilder routeBuilder;
>      protected Request request;
>
>     public StandardReuqestBean()
>     {
>                   routeBuilder = new RouteBuilder()
>                   {
>                             @Override
>                              public void configure() throws Exception
>                              {
>                                   //how to get activemq:temp:topic from the
> spring context?
>                                   //create endpoint ??
>
> from(activemq:temp:topic:dynamicAddress).bean(this,
> "doWork").routeIddynamicAddressKey);
>                              }
>                   }
>     }
>
>      @Override
>      public void setApplicationContext(ApplicationContext
> applicationContext;
>      {
>                this.applicationContext =  applicationContext;
>      }
>
>    public void publishRequest(ActionEvent event)
>    {
>              System.out.println(this.applicationContext);     //This is
> returning null
>
>              /**
>              if (  camelContext == null )
>              {
>                     camelContext  = (SpringCamelContext) applicationContext;
>              }
>              routeBuilder.addRoutesToCamelContext(camelContext;);
>              */
>
>            publisherUtil.publishRequest(request, dynamicAddress );
> //Problem 3
>    }
>
>    public void doWork()
>    {
>    }
>
>   @Override
>    public void dispose() throws Exception
>    {
>                  //Remove the dynamic route cleanup
>    }
>
> }
>
> _________________________________________--
>
> public class CamelPublisher implements IPublisherUtil
> {
>             ..................
>               public  void publishRequest( Request request,  String
> replyAddress)
>               {
>                         template.sendBodyAndHeader(destination, request,
> ,"JMSReplyTo", dynamicAddress);  // Problem 3
>                         //Taking almost 20 secs to return for a input that
> took the camelContext b  (20 secs to process, simple cases.)
>                         //Possbile to make camel context b return once it
> consumed the jms endpoint and send to third party software?
>               }
> }
>
> Problem 1:  My ApplicationContext for StandardRequestBean  is return null.
> Problem 2:  How to create the endpoint for a dynamic temp topic/queue
> instead of hardcoding the "activemq:temp:topic:"
> Problem 3:  How do i get the JMSID after I have published (immediately)
> (Low priority since i showing the request ID)
> (please note that the route in standalone camel context b, have 2 routes,
> the first route consume from the activemq destination, and pass processing
> to a third party software, which may take hours to complete.
> the second route, consume from the returned xml files and will need to go
> through more processing before sending a JMS message based on the
>
> JMSReplyTo set in the header.
>
>
> My web.xml  in case its is wrongly set up
> <web-app ....>
>          <context-param>
>                <param-name>contextConfigLoaction</param-name>
>                <param-value>/WEB-INF/applicationContext.xml</param-value>
>         </context-param>
> </web-app>
>
> Thanks and Best Regards,
> Zuff
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Dynamic-Routing-ApplicationContext-is-null-tp5720943.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: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to