Results 1 to 8 of 8

Thread: Web based Spring example using AMQP

  1. #1
    Join Date
    Dec 2010
    Posts
    10

    Default Web based Spring example using AMQP

    Looking for Web based Spring example using AMQP. Need to create a web based app for sending and receiving messages to a user or group of users. Sort of web based chat app.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    I would recommend starting with the Hello World sample from the Spring AMQP project. That exact same code should be able to run within a webapp. You could create a controller that receives an HTTP request (a chat message) and then sends that via AmqpTemplate. On the receiving side, you probably want to have an AJAX client invoking/polling another Controller that contains a Queue of received AMQP Messages.

  3. #3
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    On the client side there is also the JSON-RPC plugin in the broker (not Spring specificially, but nice to use in JavaScript). Sample: http://dev.rabbitmq.com/www-examples/chat/index.html.

  4. #4
    Join Date
    Dec 2010
    Posts
    10

    Default

    Started with using ProducerConfiguration and HelloWorldConfiguration in my spring web app. Got this exception ....am new to AMQP configuration...am missing anything to start with..

    SEVERE: StandardWrapper.Throwable
    org.springframework.context.ApplicationContextExce ption: Failed to start bean 'messageConfiguration'; nested exception is java.lang.NullPointerException
    at org.springframework.context.support.DefaultLifecyc leProcessor.doStart(DefaultLifecycleProcessor.java :169)
    at org.springframework.context.support.DefaultLifecyc leProcessor.access$1(DefaultLifecycleProcessor.jav a:154)
    at org.springframework.context.support.DefaultLifecyc leProcessor$LifecycleGroup.start(DefaultLifecycleP rocessor.java:335)
    at org.springframework.context.support.DefaultLifecyc leProcessor.startBeans(DefaultLifecycleProcessor.j ava:143)
    at org.springframework.context.support.DefaultLifecyc leProcessor.onRefresh(DefaultLifecycleProcessor.ja va:108)
    at org.springframework.context.support.AbstractApplic ationContext.finishRefresh(AbstractApplicationCont ext.java:908)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:428)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 42)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 58)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:339 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:306)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:993)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4149)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4458)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:741)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:587)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:290)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:415)
    Caused by: java.lang.NullPointerException
    at org.springframework.amqp.config.AbstractAmqpConfig uration.start(AbstractAmqpConfiguration.java:92)
    at org.springframework.context.support.DefaultLifecyc leProcessor.doStart(DefaultLifecycleProcessor.java :166)
    ... 29 more

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    If you don't mind depending on snapshot builds (instead of the milestone1 build), that code has been changed since M1. We're working on the M2 release, and hope to have it relatively soon, but it would be great if your problem is resolved by switching to the snapshot. If it's not resolved, then at least we would know exactly where in the refactored code to track it down.

  6. #6
    Join Date
    Dec 2010
    Posts
    10

    Default

    Hey Mark, where can i find the snapshot build.

    Thanks

  7. #7
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    The nightly builds are uploaded to our snapshot Maven repository. Here's a sample configuration for the <repository> element in the POM:
    Code:
    <repository>
       <id>repository.springframework.maven.snapshot</id>
       <name>Spring Framework Maven Snapshot Repository</name>
       <url>http://maven.springframework.org/snapshot</url>
    </repository>

  8. #8
    Join Date
    Dec 2010
    Posts
    10

    Default

    What would be the best way for client GUI (Web GUI) to communicate with the message listener to get the message and display in GUI.

    I guess we can poll through ajax..any other suggestions..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •