You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by dajevu <jd...@hireright.com> on 2006/05/17 17:56:43 UTC

NMR Flow scenario question

Hi,

I've got the following scenario:

1. An instance of ServiceMix running on one environment under Tomcat. It
receives an HTTP Request.
2. It populates the HTTP Request into a JMS Queue.
3. The message is consumed by another ServiceMix instance, whereby a
response is generated. 
4. The message is returned to the originating ServiceMix instance and sent
back as an HTTP Response.

Question I am facing is how to accomplish this without resorting to a custom
component, or is that my only alternative. What I am grappling with is how
to send the message over JMS, receive a reply (from my understanding, JMS
really isnt' syncronous like this, except through correlationId type tricks)
and then, in turn, use that as the HTTP response to my original HTTP
Request?

Any ideas would be great!

jeff
--
View this message in context: http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4433467
Sent from the ServiceMix - User forum at Nabble.com.


Re: NMR Flow scenario question

Posted by dajevu <jd...@hireright.com>.
Never mind, I seemed to have figured it out. In the host machine, I specified
a destinationService for the activationSpec element which housed the JMS
provider. I removed the JMS Consumer, and it worked just fine. 

jeff
--
View this message in context: http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4455338
Sent from the ServiceMix - User forum at Nabble.com.


Re: NMR Flow scenario question

Posted by dajevu <jd...@hireright.com>.
Hey Guillaume, 

I think I am getting close (and please excuse my ignorance on these
matters). What I have on the host receiving the HTTP Post is:

<sm:activationSpecs>

	<sm:activationSpec>
		<sm:component>
			<http:component>
				<http:endpoints>

					<http:endpoint service="test:MyConsumerService" endpoint="transformer" 
						role="consumer" soap="false" locationURI="http://sushi:8192/dummy" 
						defaultMep="http://www.w3.org/2004/08/wsdl/in-out" 
						targetService="test:MyProviderService"/>
				</http:endpoints>
			</http:component>
		</sm:component>
	</sm:activationSpec>

	<sm:activationSpec componentName="transformer" service="foo:transformer">
		<sm:component>
			<bean class="org.apache.servicemix.components.xslt.XsltComponent">
				<property name="xsltResource" value="xslt/strip-namespace.xslt"/>
			</bean>
		</sm:component>
	</sm:activationSpec>

	<sm:activationSpec>
		<sm:component>
			<jms:component>
				<jms:endpoints>
					<jms:endpoint service="test:MyConsumerService" 
						endpoint="myConsumer" 
						role="consumer" 
						defaultMep="http://www.w3.org/2004/08/wsdl/in-out" 
						destinationStyle="queue" 
						jmsProviderDestinationName="queue/B" 
						connectionFactory="#connectionFactory"
					    targetService="foo:transformer"/>
					<jms:endpoint service="test:MyProviderService" 
						endpoint="myProvider" 
						role="provider" 
						destinationStyle="queue" 
						jmsProviderDestinationName="queue/A" 
						connectionFactory="#connectionFactory"/>
				</jms:endpoints>
			</jms:component>
		</sm:component>
	</sm:activationSpec>
</sm:activationSpecs>

The intention is that I pass the JMS of the incoming HTTP to another maching
running SM. This other machine would then consume this XML, transform it in
some way, and pass it back. This is what I have on the other box:

<sm:activationSpecs>

	<sm:activationSpec componentName="transformer" service="foo:transformer"
destinationService="test:MyConsumerService">
		<sm:component>
			<bean class="org.apache.servicemix.components.xslt.XsltComponent">
				<property name="xsltResource" value="xslt/rm-request-url.xslt"/>
			</bean>
		</sm:component>
	</sm:activationSpec>

	<sm:activationSpec>
		<sm:component>
			<jms:component>
				<jms:endpoints>
					<jms:endpoint service="test:MyConsumerService" 
					endpoint="myConsumer" 
					role="consumer" 
					defaultMep="http://www.w3.org/2004/08/wsdl/in-out" 
					destinationStyle="queue" 
					jmsProviderDestinationName="queue/A"
					connectionFactory="#connectionFactory" 
					targetService="foo:transformer"/>
				</jms:endpoints>
			</jms:component>
		</sm:component>
	</sm:activationSpec>
</sm:activationSpecs>

As you might imagine, what's happening is that the first box (lets call it
the host), is immediately picking up the JMS message prior to the other box
(called client) receiving and transforming it.

Do I need to setup a seperate queue to send the reply to? If so, how am I
assured that the messages are correlated?

In the future, I do hope to payback my gratitude once I get better
understanding of things through helping out with documentation etc.

Thanks,

jeff
--
View this message in context: http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4454845
Sent from the ServiceMix - User forum at Nabble.com.


Re: NMR Flow scenario question

Posted by Guillaume Nodet <gn...@gmail.com>.
Sorry to say that, but i'd like you to try with servicemix-http and
servicemix-jms components.
You will find some docs at
   http://incubator.apache.org/servicemix/servicemix-http.html
   http://incubator.apache.org/servicemix/servicemix-jms.html

They both handle InOut meps, but jms lightweight components do not and thus
you receive this exception back.

Cheers,
Guillaume Nodet

On 5/17/06, dajevu <jd...@hireright.com> wrote:
>
>
> First off, I want to thank you for all of your help -- you guys are
> fantastic!
>
> I am still struggling to understand how to properly configure this. On the
> webserver/client box (where the incoming HTTP request is received), I've
> configured SM such as:
>
>       <sm:activationSpecs>
>        <sm:activationSpec componentName="httpBinding"
> service="foo:httpBinding" destinationService="my:outputSender">
>         <sm:component><bean
> class="org.apache.servicemix.components.http.HttpInOutBinding"
> /></sm:component>
>       </sm:activationSpec>
>
>       <sm:activationSpec componentName="inputReceiver"
> service="my:inputReceiver">
>         <sm:component>
>           <bean
> class="org.apache.servicemix.components.jms.JmsInUsingJCABinding">
>         <property name="jcaContainer" ref="jencks"/>
>         <property name="activationSpec">
>           <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
>             <property name="destination"
> value="demo.org.apache.servicemix.result"/>
>             <property name="destinationType" value="javax.jms.Topic"/>
>           </bean>
>         </property>
>           </bean>
>         </sm:component>
>       </sm:activationSpec>
>
>       <sm:activationSpec componentName="outputSender"
> service="my:outputSender">
>         <sm:component>
>           <bean
> class="org.apache.servicemix.components.jms.JmsSenderComponent">
>         <property name="template">
>           <bean class="org.springframework.jms.core.JmsTemplate">
>             <property name="connectionFactory">
>               <ref local="jmsFactory"/>
>             </property>
>             <property name="defaultDestinationName"
> value="demo.org.apache.servicemix.source"/>
>             <property name="pubSubDomain" value="true"/>
>           </bean>
>         </property>
>           </bean>
>         </sm:component>
>       </sm:activationSpec>
>
> And, on the other box running SM (which will receive the message from the
> other, do a little transformation, and return it):
>
>                         <sm:activationSpec componentName="myJmsReceiver"
> service="foo:myJmsReceiver"
>                                 destinationService="foo:transformer">
>                                 <sm:component><bean
> class="org.apache.servicemix.components.jms.JmsReceiverComponent">
>                                         <property name="template">
>                                                 <bean class="
> org.springframework.jms.core.JmsTemplate">
>                                                         <property
> name="connectionFactory">
>                                                                 <ref
> local="jmsFactory"/>
>                                                         </property>
>                                                         <property
> name="defaultDestinationName"
> value="demo.org.apache.servicemix.source"/>
>                                                         <property
> name="pubSubDomain" value="true"/>
>                                                 </bean>
>                                         </property>
>                                 </bean></sm:component>
>                         </sm:activationSpec>
>
>                         <!-- START SNIPPET: xslt -->
>                         <sm:activationSpec componentName="transformer"
> service="foo:transformer"
> destinationService="foo:transformedSender">
>                                 <sm:component><bean
> class="org.apache.servicemix.components.xslt.XsltComponent">
>                                         <property name="xsltResource"
> value="xslt/rm-request-url.xslt"/>
>                                 </bean></sm:component>
>                         </sm:activationSpec>
>                         <!-- END SNIPPET: xslt -->
>
>
>                         <sm:activationSpec
> componentName="transformedSender"
> service="foo:transformedSender">
>                                 <sm:component><bean
> class="org.apache.servicemix.components.jms.JmsSenderComponent">
>                                         <property name="template">
>                                                 <bean class="
> org.springframework.jms.core.JmsTemplate">
>                                                         <property
> name="connectionFactory">
>                                                                 <ref
> local="jmsFactory"/>
>                                                         </property>
>                                                         <property
> name="defaultDestinationName"
> value="demo.org.apache.servicemix.result"/>
>                                                         <property
> name="pubSubDomain" value="true"/>
>                                                 </bean>
>                                         </property>
>                                 </bean></sm:component>
>                         </sm:activationSpec>
>
> I've tried many different permutations, but usually, the message I always
> get back on the webserver box is:
>
> javax.servlet.ServletException: illegal exchange status: done
>
> I've confirmed that the transformed message is arriving back in the result
> queue, but I still don't know how to get that back as the HTTP Response.
>
> I still don't have a solid understanding of NMR (even after reading the
> JBI,
> but that's not the easiest doc to follow).
>
> Thanks again for all of your help!
>
> jeff
>
> --
> View this message in context:
> http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4436884
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: NMR Flow scenario question

Posted by dajevu <jd...@hireright.com>.
First off, I want to thank you for all of your help -- you guys are
fantastic!

I am still struggling to understand how to properly configure this. On the
webserver/client box (where the incoming HTTP request is received), I've
configured SM such as:

      <sm:activationSpecs>
       <sm:activationSpec componentName="httpBinding"
service="foo:httpBinding" destinationService="my:outputSender">
        <sm:component><bean
class="org.apache.servicemix.components.http.HttpInOutBinding"
/></sm:component>
      </sm:activationSpec>

      <sm:activationSpec componentName="inputReceiver"
service="my:inputReceiver">
        <sm:component>
          <bean
class="org.apache.servicemix.components.jms.JmsInUsingJCABinding">
        <property name="jcaContainer" ref="jencks"/>
        <property name="activationSpec">
          <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
            <property name="destination"
value="demo.org.apache.servicemix.result"/>
            <property name="destinationType" value="javax.jms.Topic"/>
          </bean>
        </property>
          </bean>
        </sm:component>
      </sm:activationSpec>

      <sm:activationSpec componentName="outputSender"
service="my:outputSender">
        <sm:component>
          <bean
class="org.apache.servicemix.components.jms.JmsSenderComponent">
        <property name="template">
          <bean class="org.springframework.jms.core.JmsTemplate">
            <property name="connectionFactory">
              <ref local="jmsFactory"/>
            </property>
            <property name="defaultDestinationName"
value="demo.org.apache.servicemix.source"/>
            <property name="pubSubDomain" value="true"/>
          </bean>
        </property>
          </bean>
        </sm:component>
      </sm:activationSpec>

And, on the other box running SM (which will receive the message from the
other, do a little transformation, and return it):

			<sm:activationSpec componentName="myJmsReceiver"
service="foo:myJmsReceiver" 
				destinationService="foo:transformer">
				<sm:component><bean
class="org.apache.servicemix.components.jms.JmsReceiverComponent">
					<property name="template">
						<bean class="org.springframework.jms.core.JmsTemplate">
							<property name="connectionFactory">
								<ref local="jmsFactory"/>
							</property>
							<property name="defaultDestinationName"
value="demo.org.apache.servicemix.source"/>
							<property name="pubSubDomain" value="true"/>
						</bean>
					</property>
				</bean></sm:component>
			</sm:activationSpec>
			
			<!-- START SNIPPET: xslt -->
			<sm:activationSpec componentName="transformer" service="foo:transformer"
destinationService="foo:transformedSender">
				<sm:component><bean
class="org.apache.servicemix.components.xslt.XsltComponent">
					<property name="xsltResource" value="xslt/rm-request-url.xslt"/>
				</bean></sm:component>
			</sm:activationSpec>
			<!-- END SNIPPET: xslt -->
			
			
			<sm:activationSpec componentName="transformedSender"
service="foo:transformedSender">
				<sm:component><bean
class="org.apache.servicemix.components.jms.JmsSenderComponent">
					<property name="template">
						<bean class="org.springframework.jms.core.JmsTemplate">
							<property name="connectionFactory">
								<ref local="jmsFactory"/>
							</property>
							<property name="defaultDestinationName"
value="demo.org.apache.servicemix.result"/>
							<property name="pubSubDomain" value="true"/>
						</bean>
					</property>
				</bean></sm:component>
			</sm:activationSpec>		

I've tried many different permutations, but usually, the message I always
get back on the webserver box is:

javax.servlet.ServletException: illegal exchange status: done

I've confirmed that the transformed message is arriving back in the result
queue, but I still don't know how to get that back as the HTTP Response.

I still don't have a solid understanding of NMR (even after reading the JBI,
but that's not the easiest doc to follow).

Thanks again for all of your help!

jeff

--
View this message in context: http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4436884
Sent from the ServiceMix - User forum at Nabble.com.


Re: NMR Flow scenario question

Posted by dajevu <jd...@hireright.com>.
Great -- I'll give it a shot. I didn't realize the JMS could be InOut. 

jeff
--
View this message in context: http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4433796
Sent from the ServiceMix - User forum at Nabble.com.


Re: NMR Flow scenario question

Posted by Guillaume Nodet <gn...@gmail.com>.
Just use the servicemix-http and servicemix-jms components.
The servicemix-jms can handle InOut meps both as a consumer and a provider.
It uses a temporary destination and waits for the response to come back.
In short, just create an http consumer endpoint (with an InOut mep) that
send exchanges to a jms provider endpoint.

On the other side, create a jms consumer endpoint specifying an InOut mep
which will send exchange to whatever you want.

Cheers,
Guillaume Nodet

On 5/17/06, dajevu <jd...@hireright.com> wrote:
>
>
> Hi,
>
> I've got the following scenario:
>
> 1. An instance of ServiceMix running on one environment under Tomcat. It
> receives an HTTP Request.
> 2. It populates the HTTP Request into a JMS Queue.
> 3. The message is consumed by another ServiceMix instance, whereby a
> response is generated.
> 4. The message is returned to the originating ServiceMix instance and sent
> back as an HTTP Response.
>
> Question I am facing is how to accomplish this without resorting to a
> custom
> component, or is that my only alternative. What I am grappling with is how
> to send the message over JMS, receive a reply (from my understanding, JMS
> really isnt' syncronous like this, except through correlationId type
> tricks)
> and then, in turn, use that as the HTTP response to my original HTTP
> Request?
>
> Any ideas would be great!
>
> jeff
> --
> View this message in context:
> http://www.nabble.com/NMR-Flow-scenario-question-t1637079.html#a4433467
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet