Question

We are using active mq with Mule ESB JMS for our webservices. It is working fine. But the problem is, even the request is forwarded to my services from queue, processed and giving the response back, but still in the Active MQ web console, Number Of Pending Messages showing the total no.of requests. Web Console :: enter image description here

Flow diagram,

Flow in Mule is ::

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
    <flow name="vbrtestmulejmsFlow1" doc:name="vbrtestmulejmsFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8888" doc:name="HTTP" path="AMServices">
         <set-property propertyName="Content-Type" value="text/xml"/>
        </http:inbound-endpoint>
        <object-to-string-transformer doc:name="Object to String" mimeType="text/xml"/>
        <jms:outbound-endpoint queue="servicesQueue" connector-ref="Active_MQ" doc:name="JMS" responseTimeout="1000000" mimeType="text/xml" >
        </jms:outbound-endpoint>

        <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="5050" path="MyServices" method="POST" doc:name="HTTP" contentType="text/xml">
          <set-property propertyName="Content-Type" value="text/xml"/>
        </http:outbound-endpoint>
    </flow>
Was it helpful?

Solution

Your flow sends the message received by the inbound HTTP endpoint to both the JMS outbound endpoint and the HTTP outbound endpoint.

So it's expected that the servicesQueue will contain 6 messages and that at the same time MyServices gets called 6 times.

Your intention is unclear but if what you wanted instead was to have servicesQueue act as an intermediary between the inbound and outbound HTTP endpoints then you need to cut your flow in two:

<flow name="AMServiceToQueue">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost"
          port="8888" path="AMServices">
     <set-property propertyName="Content-Type" value="text/xml"/>
    </http:inbound-endpoint>
    <object-to-string-transformer mimeType="text/xml"/>

    <jms:outbound-endpoint queue="servicesQueue" connector-ref="Active_MQ"
         exchange-pattern="request-response" responseTimeout="1000000" />
</flow>

<flow name="QueueToMyServices">
    <jms:inbound-endpoint queue="servicesQueue" connector-ref="Active_MQ"
         exchange-pattern="request-response" />

    <http:outbound-endpoint exchange-pattern="request-response" host="localhost"
          port="5050" path="MyServices" method="POST" contentType="text/xml">
      <set-property propertyName="Content-Type" value="text/xml"/>
    </http:outbound-endpoint>
</flow>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top