I developed a small project that uses spring for instantiation Topologies. Also, Cassandra driver is initialized at run time (once it is called from storm factories).
You can see the project in https://github.com/miguelangelprogramacion/spring4-storm-cassandra 2015-09-29 16:27 GMT+02:00 Ravi Sharma <[email protected]>: > Yes this is for annotation also... > > you can call this method in prepare() method of bolt and onOpen() method > in every Spout and make sure you don't use any autowire bean before this > call. > > > > > Ravi. > > > > > On Tue, Sep 29, 2015 at 2:22 PM, Ankur Garg <[email protected]> wrote: > >> Hi Ravi , >> >> Thanks for your reply . I am using annotation based configuration and >> using >> Spring Boot. >> >> Any idea how to do it using annotations ? >> >> >> >> On Tue, Sep 29, 2015 at 6:41 PM, Ravi Sharma <[email protected]> wrote: >> >> > Bolts and Spouts are created by Storm and not known to Spring Context. >> You >> > need to manually add them to SpringContext, there are few methods >> available >> > i.e. >> > >> > >> > >> SpringContext.getContext().getAutowireCapableBeanFactory().autowireBeanProperties(this, >> > AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, false); >> > >> > SpringContext is my own class where i have injected SpringContext so >> > SpringContext.getContext() returns the actuall Spring Context >> > >> > >> > >> > >> > Ravi. >> > >> > >> > On Tue, Sep 29, 2015 at 1:03 PM, Ankur Garg <[email protected]> >> wrote: >> > >> > > Hi , >> > > >> > > I am building a Storm topology with set of Spouts and Bolts and also >> > using >> > > Spring for Dependency Injection . >> > > >> > > Unfortunately , none of my fields are getting autowired even though I >> > have >> > > declared all my spouts and Bolts as @Components . >> > > >> > > However the place where I am declaring my topology , Spring is working >> > fine >> > > . >> > > >> > > Is it because cluster.submitTopology("test", conf, >> > > builder.createTopology()) >> > > submits the topology to a cluster (locally it spawns different thread >> > for >> > > Spouts and Bolts) that Autowiring is not working? >> > > >> > > Please suggest . >> > > >> > >> > >
