Announcement Announcement Module
No announcement yet.
integrating in web app Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • integrating in web app

    I am trying to get get spring-integration working inside a new web-app. I have a simple pub-sub setup to check that the technology is working correctly inside the stack . I can see this working correctly inside an integration test which fires up our full application context. Unfortunately when I try to deploy using maven and jetty my pub-sub doesn't work. All the plumbing seems to have been created okay (the channels and - I think - the message bus are present in the context). However nothing goes through the pipes. It's almost as if the system has been been created but never kicked into action.

    Has anybody encountered a similar situation? All suggestions gratefully received!

  • #2
    Having the same problem...

    I'm experiencing the same problem. I have run the cafe successfully in *non-webapp* mode - i.e. just running it on the local machine. When I create a webapp, using wtp, and then create the spring context etc, the web app runs and the context does get read (I see that the various endpoints etc are "registered" when I look at the console / log). But the beans are only registered, and are not active...because nothing happens! It's possible to define the class as a spring bean, and give it an init-method. Sure enough, this will issue the correct number of DrinkOrders, and if you *inject* the Cafe object inside the bean, you'll see that the Cafe does indeed get called, and has those orders passed to it (see the cafe.placeOrder methodthat's called from the CafeDemo class). However...that's as far as it goes....the cafe seems to send its orders to an endpoint but neither the DrinkRouter, Order Splitter or Barista classes ever receive anything....would be great if anyone can help.


    • #3
      OK - one working solution..

      Not the most elegant - but it'l get things working 4 u in a WebApp.
      1. Start a new web project in e.g. eclipse.
      2. In your java/src folder, create 2 packages - one called org.mydomain.quote, and another called org.mydomain.base (you can call them whatever you like, really - names are not important for this).
      3. Now add a simple Spring-beans based applicationContext.xml - placing this inside your *org.mydomain.base* package. It's now on the classpath.
      4. Edit your project's web.xml as follows:
      <listenerclass>org.springframework.web.context.Con textLoaderListener</listener-class>
      5. At this stage, your main application context will load when your web app starts. So far so good!
      6. Now we'll add a class to the org.mydomain.base package. It only has one simple we'll see...
      --Create the following java class called
      package com.lightweightplanet.base;

      import ationContext;
      import plicationContext;

      * @author : Your Name
      public class Starter {

      public void startIt() {
      AbstractApplicationContext context = new ClassPathXmlApplicationContext("org/mydomain/quote/quoteDemo.xml");
      7. As you'll spot at once...we're just using one of Mark's demo apps - in this case the QuoteDemo. The idea is that we will invoke the context used in that demo from the first context (our applicationContext.xml).
      8. Just add a bean into your base package's aplicationContext.xml as follows:
      <bean id="quotecontextStart" class="com.lightweightplanet.base.Starter" init-method="startIt">
      9. Nearly done...but we just need something to actually start!! So let's copy all the files from Mark's quoteDemo package in the samples directory, and paste them into your webap's 2nd package - the org.mydomain.quote that you created earlier. The class (the one with a "main" method) you do not need, so that can be thrown away...but keep the others, and make sure that you include the quoteDemo.xml *inside* the org.mydomain.quote package/folder, so that it's also on the app's class path.

      10. Take care to re-designate the package names on every class, and take care also to edit the quoteDemo.xml file - you'll need to change the path on each bean defined in there to reflect your own *org.mydomain.quote* package e.g. the quoteDemo.xml contents would look like:


      <channel id="quotes"/>

      <beans:bean id="publisher" class="org.mydomain.quote.QuotePublisher"/>

      <beans:bean id="subscriber" class="org.mydomain.quote.QuoteSubscriber"/>

      That's it! You're done. Run your webapp, and you'll see the quotes demo is running....the output should be visible on your console.

      Hope this helps - have great fun with adding some dynamism to your web-apps!



      • #4
        Indeed, the message bus needs to be started (not necessarily the entire context, but that will cascade the call).

        I will be committing an autoStartup flag for the MessageBus shortly (see:



        • #5
          Many thanks Mark