Announcement Announcement Module
Collapse
No announcement yet.
HTTP to JMS : How to? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP to JMS : How to?

    Hi,

    I need some help in accomplishing the following :

    HTTP Inbound Gateway --> store the message into a JMS destination --> If sucessful, send a positive ack back ; otherwise a negative ack (xmls) back to the invoker.

    Approach 1:
    I tried to achieve it in the following fashion :

    HTTP Inbound gateway --> JMS backed message channel -->Service Activator invoking a pojo service which prepares required positive ack --> to a reply channel --> back to gateway;

    Obviously, my assumption about the JMS backed channel is wrong and the exception thrown is :

    org.springframework.integration.MessagingException : failed to handle incoming JMS Message
    Caused by: org.springframework.integration.support.channel.Ch annelResolutionException: no output-channel or replyChannel header available;


    Approach 2 :

    Now I am hoping to achieve the same using a normal channel (instead of a JMS channel) and then inject an instance of another channel into a service activator ( this 'another channel' will be bound to a JMS adapter) and once execution of that channel suceeds, prepare the ack XML within the service activator and send it to a reply channel.

    Somehow I feel I am over-engineering with approach 2 and missing something.
    Any ideas are greatly appreciated on how this can be accomplished as I am new to Spring Integration.

    Detailed logs :

    Attachment

    Regards,
    Sanket.
    Attached Files
    Last edited by rksanket; Aug 11th, 2011, 11:37 AM.

  • #2
    I am struck with this use case and really need some help.

    I need to prepare a response XML and send it back through the HTTP Inbound gateway once the incoming message is sucessfully stored into JMS store.

    When I put sort of a parallel branch as in the below code, (because there is no other way to do it), it either stores the message into JMS OR sends an ack back (preparation of this message is inside the pojoService). What I really want is to send the prepared ack back only after the incoming message is stored into JMS.


    [CODE<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jms="http://www.springframework.org/schema/integration/jms"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
    http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd
    http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.0.xsd
    http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-file="http://www.springframework.org/schema/integration/file"
    xmlns:int-http="http://www.springframework.org/schema/integration/http">

    <bean id="pojoService" class="com.asps.integration.ContentEnrich" />

    <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL">
    <value>tcp://localhost:61616</value>
    </property>
    </bean>

    <bean id="outQ" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="queue.demo" />
    </bean>

    <int-http:inbound-gateway name="/abcd" supported-methods="GET,POST"
    mapped-response-headers="Content-Type"
    request-channel="requestChannel" id="receiveMessage" />

    <int:channel id="requestChannel"></int:channel>

    <int:service-activator input-channel="requestChannel"
    ref="pojoService" method="enrich">
    </int:service-activator>
    <jms:outbound-channel-adapter channel="requestChannel"></jms:outbound-channel-adapter>
    </beans>[/CODE]

    Comment


    • #3
      Here is the full code :

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns:jms="http://www.springframework.org/schema/integration/jms"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      		http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
      		http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd
      		http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.0.xsd
      		http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd"
      	xmlns:int="http://www.springframework.org/schema/integration"
      	xmlns:int-file="http://www.springframework.org/schema/integration/file"
      	xmlns:int-http="http://www.springframework.org/schema/integration/http">
      	
      	<bean id="pojoService" class="com.asps.integration.ContentEnrich" />
      
      	<bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
      		<property name="brokerURL">
      			<value>tcp://localhost:61616</value>
      		</property>
      	</bean>
      
      	<bean id="outQ" class="org.apache.activemq.command.ActiveMQQueue">
      		<constructor-arg value="queue.demo" />
      	</bean>
      
      	<int-http:inbound-gateway name="/abcd" supported-methods="GET,POST"
      		mapped-response-headers="Content-Type"
      		request-channel="requestChannel" id="receiveMessage" />
      
      	<int:channel id="requestChannel"></int:channel>
      	
      	<int:service-activator input-channel="requestChannel"
      		ref="pojoService" method="enrich">
      	</int:service-activator>
      	<jms:outbound-channel-adapter channel="requestChannel"></jms:outbound-channel-adapter>
      </beans>

      Comment


      • #4
        Not enough constructs available in SI for synchronous HTTP request-reply with JMS

        It seems like there are not enough constructs available in SI to accomplish this simple task :-

        Receive message over HTTP --> store to JMS --> Respond with a positive / negative
        ack (xml) after a successful storage.

        I am struggling to achieve this since last 3 days and docmentation is little vague.

        can some pro please pick up this problem and suggest an alternative? I do not have the option of having something produce a JMS reply; JMS gateway is not an option. JMS outbound like behaviour (one way) with scope to prepare a reply after the storage.

        Can a pro please pick up this thread suggest something?

        Comment


        • #5
          Code:
          http.ib.gateway->transformer->pub-sub.channel->jms.ob.adapter(order=1)
                                                       ->result.transformer(order=2)
          In other words, subscribe ordered endpoints to a pub/sub channel. Don't put an output channel on the second subscriber; it's output will be sent to the gateway via a reply channel in the message header.

          If the JMS operation succeeds, the other subscriber will be invoked; if it fails, an exception will be thrown. If you want to massage the result in the event of a failure, put an error channel and error flow on the ib,gateway.

          HTH.

          ...doc[ u ]mentation is little vague
          We can't cover every use case in detail; if you have specific areas where you feel improvement is needed, please open a JIRA issue, or post your suggestions in the Sticky thread about the reference manual http://forum.springsource.org/forumd...42-Integration

          Comment

          Working...
          X