Results 1 to 7 of 7

Thread: Cloudfoundry RabbitMQ -Connection refused

  1. #1
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default Cloudfoundry RabbitMQ -Connection refused

    Hi

    I am getting following Stack error when i try to connect RabbitMQ,

    My configuration :

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schem...rabbit-1.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <rabbit:connection-factory id="rabbitConnectionFactory" />
    <rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory" />
    <rabbit:admin connection-factory="rabbitConnectionFactory" />
    <rabbit:queue name="myqueue" />
    </beans>


    ================================================== ================================================== ==
    Error stack :

    java.net.ConnectException: Connection refused


    org.springframework.amqp.rabbit.connection.RabbitU tils.convertRabbitAccessException(RabbitUtils.java :106)
    org.springframework.amqp.rabbit.connection.Abstrac tConnectionFactory.createBareConnection(AbstractCo nnectionFactory.java:118)
    org.springframework.amqp.rabbit.connection.Caching ConnectionFactory.createConnection(CachingConnecti onFactory.java:179)
    org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils$1.createConnection(ConnectionFacto ryUtils.java:77)
    org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils.doGetTransactionalResourceHolder(C onnectionFactoryUtils.java:121)
    org.springframework.amqp.rabbit.connection.Connect ionFactoryUtils.getTransactionalResourceHolder(Con nectionFactoryUtils.java:67)
    org.springframework.amqp.rabbit.connection.RabbitA ccessor.getTransactionalResourceHolder(RabbitAcces sor.java:100)
    org.springframework.amqp.rabbit.core.RabbitTemplat e.execute(RabbitTemplate.java:402)
    org.springframework.amqp.rabbit.core.RabbitTemplat e.receive(RabbitTemplate.java:267)
    org.springframework.amqp.rabbit.core.RabbitTemplat e.receiveAndConvert(RabbitTemplate.java:296)
    smse.com.au.service.MessageServiceImpl.resiveMessa ge(MessageServiceImpl.java:33)
    smse.com.au.MessageController.list(MessageControll er.java:39)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    org.springframework.web.filter.HiddenHttpMethodFil ter.doFilterInternal(HiddenHttpMethodFilter.java:7 7)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:859)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
    java.lang.Thread.run(Thread.java:662)

  2. #2
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    Anyone can help ?

    Placidus

  3. #3
    Join Date
    Oct 2011
    Location
    San Francisco
    Posts
    2

    Default You need to tell Spring that your Rabbit Connection parameters come from CloudFoundry

    cf http://support.cloudfoundry.com/entr...ng-application
    This means adding the cloud: namespace declaration, and define the cloud:rabbit-connection-factory

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xmlns:cloud="http://schema.cloudfoundry.org/spring"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schem...ng-mvc-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-3.0.xsd
    http://www.springframework.org/schema/rabbit http://www.springframework.org/schem...rabbit-1.0.xsd
    http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.7.xsd">
    <context:component-scan base-package="com.rabbitmq.cftutorial.simple"/>
    <mvc:annotation-driven/>

    <!-- Obtain a connection to the RabbitMQ via cloudfoundry-runtime: -->
    <cloud:rabbit-connection-factory id="connectionFactory"/>

    <!-- Set up the AmqpTemplate/RabbitTemplate: -->
    <rabbit:template connection-factory="connectionFactory"/>

    <!-- Request that queues, exchanges and bindings be automatically
    declared on the broker: -->
    <rabbit:admin connection-factory="connectionFactory"/>

    <!-- Declare the "messages" queue: -->
    <rabbit:queue name="messages" durable="true"/>
    </beans>
    --
    Patrick Chanezon
    Senior Director, Developer Relations, VMware
    http://cloudfoundry.com/
    http://wordpress.chanezon.com/

  4. #4
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    Hi chanezon

    it's not work.


    is it working for you?


    i have add the following to pom.xml

    Basically i have followed the all the steps in

    http://support.cloudfoundry.com/entr...ng-application

    but it's not working too.


    I do have question?

    1. why it's different to : Database connection factory : I used mysql database resources it's work fine NOT need any [cloudfoundry-runtime jar runtime ] i think rabbit also should NOT used the
    cloudfoundry-runtime , if it's need then, if we wont to run the application non - cloud env then it's has to change [connection factory ]

    As fare as i understand cloud-foundry should proved proxy type of thing to rap around the underline resources



    Placidus.


    ++++++++++++++++++++++++++++++++
    <dependency>
    <groupId>org.cloudfoundry</groupId>
    <artifactId>cloudfoundry-runtime</artifactId>
    <version>0.7.1</version>
    </dependency>

    ++++++++++++++++++++++++++++++++
    Last edited by placidus; Oct 20th, 2011 at 11:30 PM.

  5. #5
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    Anyone can help ?

    Placidus

  6. #6
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Is the RabbitMQ service provisioned? Is it definitely bound to your application?

    As to your secondary question, you should no longer need the cloud namespace if you're happy to have your connection factory reconfigured. The org.springframework.amqp.rabbit.connection.Connect ionFactory class is automatically rewired to use the bound RabbitMQ service. However, this reconfiguration does not happen if you use <cloud:...> anywhere in your application context configuration.

    Hope that helps,

    Peter

  7. #7
    Join Date
    Aug 2011
    Location
    Sydney
    Posts
    37

    Default

    this blog explain all my questions.


    http://blog.springsource.com/2011/11...configuration/


    Placidus.

Posting Permissions

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