You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by DavidSigh <lu...@gmail.com> on 2009/01/22 17:59:19 UTC

CXF --> JMS

Hello,

I'm a SMX newbie and try to play around a little bit. For learning to
develop on SMX I built up restaurant odering case with ServiceMix, CXF and
JMS and urgently need some architectural help for my scenario.

My idea is to have a CXF based Webservice that supports two operations:
1. orderCalcTotal
Request: contains quantities and prices
Respose: is the totalResult
2. placeOrder
only a Request that places serval items (also said: an order)

My intended Message flow is.

SoapRequest "orderCalcTotal" --> CXF BC --> CXF SE with a Bean that performs
the calcTotal logic and returns a result  --> Response to the SOAPClient

This scenario is already working.

The placeOrder request has to be processed differently since I wanna place
Order into the NMR, validate and split it in order to send it to different
clients (as an example: Kichten and Bar for food and drink orders).

My idea of the flow is kind of this that the:
1. SoapRequest "placeOrder" to the CXF BC/SE
2. The CXF XX processes the orders (as XML/SOAP or JBI Normalized Message)
3. to a JMS Provider --->ActiveMQ --->JMS Consumer and the messge gets
further processed (this is already working )


Do you have an hints how to configure CXF to dispach "placeOrder" Request to
the JMS Provider and on the other hand side still have the "orderCalcTotal"
request that returns a SOAP response to the client? Or do I have
programmatically create the placeOrder message in my CXF-SE client and put
in on JMS or ActiveMQ

Thank you very much for your help.
Here my configuration Files:

---------WSDL Snippet!!!
------------------------------------------------------------


	<!--  input message with all the orders -->
	<wsdl:message name="orderCalcTotalRequest">
		<wsdl:part element="osesb:calcTotal" name="parameters" />
	</wsdl:message>
	<!-- order confirmation message -->
	<wsdl:message name="orderCalcTotalResponse">
		<wsdl:part element="osesb:orderCofirmation" name="parameters" />
	</wsdl:message>
	
	<!-- order Message for further processing in the ESB -->
	<wsdl:message name="placeOrderRequest">
		<wsdl:part element="osesb:order" name="parameters" />
	</wsdl:message>
	
	
	<wsdl:portType name="COSPortType">
		<wsdl:operation name="orderCalcTotal">
			<wsdl:input message="osesb:orderCalcTotalRequest"/>
			<wsdl:output message="osesb:orderCalcTotalResponse"/>
		</wsdl:operation>
		<wsdl:operation name="placeOrder">
			<wsdl:input message="osesb:placeOrderRequest"/>
        </wsdl:operation>
	</wsdl:portType>
	
	<wsdl:binding name="COSSoapBinding" type="osesb:COSPortType">
		<soap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
		
		<wsdl:operation name="orderCalcTotal">
			<soap:operation soapAction="http://ps.com/COS/orderCalcTotal" />
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
			<wsdl:output>
				<soap:body use="literal" />
			</wsdl:output>
		</wsdl:operation>
		
		<wsdl:operation name="placeOrder">
			<soap:operation soapAction="http://ps.com/COS/placeOrder"/>
			<wsdl:input>
				<soap:body use="literal" />
			</wsdl:input>
		</wsdl:operation>
		
	</wsdl:binding>
	
	<wsdl:service name="COSService">
		<wsdl:port binding="osesb:COSSoapBinding" name="COSSoap">
			<soap:address location="http://localhost:8080/services/cos" />
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

---------WSDL END--------------------------------------------------

---------cxf-bc configuraton xbean
snippet--------------------------------------------------

	
	<cxfbc:consumer wsdl="classpath:COS.wsdl" 
		service="cos:COSService"
		interfaceName="cos:COSPortType"
		targetEndpoint="COSSoap"
		targetService="cos:COSService" 
		targetInterface="cos:COSPortType" />
		

---------cxf-bc configuraton xbean
END--------------------------------------------------


---------cxf-se configuraton xbean snippet
--------------------------------------------------
´
  <bean id="COSServiceImpl"
class="com.ps.component.CustomerOrderServiceImpl" init-method="init"/>

  <classpath>
    <location>.</location>
  </classpath>

  <cxfse:endpoint>
     <cxfse:pojo>
       <bean class="com.ps.cos.COSPortTypeImpl">
        <property name="delegate" ref="COSServiceImpl"/>
      </bean>
    </cxfse:pojo>
  </cxfse:endpoint>
---------cxf-se configuraton xbean
END--------------------------------------------------



---------Jms configuraton xbean snippet
--------------------------------------------------
	<jms:provider service="cos:COSServiceProvider"
endpoint="COSServiceProvider"
		destinationName="order.input" connectionFactory="#connectionFactory" />

	<jms:consumer service="esb:simpleConsumer" endpoint="simpleEndpoint"
		targetService="esb:errorHandler" destinationName="order.input"
		connectionFactory="#connectionFactory" />
	<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL" value="tcp://localhost:61616" />
	</bean>

---------Jms configuraton xbean snippet
--------------------------------------------------


-- 
View this message in context: http://www.nabble.com/CXF---%3E-JMS-tp21608439p21608439.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: CXF --> JMS

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

There are 2 different ways you could do this... 

--------------------

The first and simpler/nonelegant way is given below but it does not avoid a
hop to the JMS consumer in all situations

       CXF-BC --> Routing Slip --> CXF-SE -- |
                                 ^                         |
                                 |                     SMX-Bean --> JMS
Producer --> JMS Consumer
                                 |                          |
                                 ---------------------

In this case the key is that the CXF-SE is a pass through for the placeOrder
request and allows the request to go to the SMX-Bean. The SMX-Bean then
calls the JMS Producer if the request is a placeOrder request. If the
request is an orderCalcTotal, then the SMX Bean simply acts as a pass
through.
 
-----------------------

The other way to do this is to introduce a Servicemix Bean that acts as a
Content Based router. Since the regular EIP content based router only deals
with In-Only MEPs this cannot be used in the scenario.

The architecture is as follows

                                                        |--> CXF-SE
      CXF-BC --> SXM-Bean (does CBR) --|
                                                        |--> JMS-Producer
--> JMS-Consumer

For more details on how to craft this bean, please take a look at the source
code for Wiretap and Content Based Router and develop accordingly.

BTW, this bean needs to do dynamic routing and not the explicit routing as
done using your spring configuration. The code for this bean is more
involved and needs to be crafted carefully with support for ME fault and
exception handling.

-------------------------

Cheers,

Ashwin...

DavidSigh wrote:
> 
> Hello,
> 
> I'm a SMX newbie and try to play around a little bit. For learning to
> develop on SMX I built up restaurant odering case with ServiceMix, CXF and
> JMS and urgently need some architectural help for my scenario.
> 
> My idea is to have a CXF based Webservice that supports two operations:
> 1. orderCalcTotal
> Request: contains quantities and prices
> Respose: is the totalResult
> 2. placeOrder
> only a Request that places serval items (also said: an order)
> 
> My intended Message flow is.
> 
> SoapRequest "orderCalcTotal" --> CXF BC --> CXF SE with a Bean that
> performs the calcTotal logic and returns a result  --> Response to the
> SOAPClient
> 
> This scenario is already working.
> 
> The placeOrder request has to be processed differently since I wanna place
> Order into the NMR, validate and split it in order to send it to different
> clients (as an example: Kichten and Bar for food and drink orders).
> 
> My idea of the flow is kind of this that the:
> 1. SoapRequest "placeOrder" to the CXF BC/SE
> 2. The CXF XX processes the orders (as XML/SOAP or JBI Normalized Message)
> 3. to a JMS Provider --->ActiveMQ --->JMS Consumer and the messge gets
> further processed (this is already working )
> 
> 
> Do you have an hints how to configure CXF to dispach "placeOrder" Request
> to the JMS Provider and on the other hand side still have the
> "orderCalcTotal" request that returns a SOAP response to the client? Or do
> I have programmatically create the placeOrder message in my CXF-SE client
> and put in on JMS or ActiveMQ
> 
> Thank you very much for your help.
> Here my configuration Files:
> 
> ---------WSDL Snippet!!!
> ------------------------------------------------------------
> 
> 
> 	<!--  input message with all the orders -->
> 	<wsdl:message name="orderCalcTotalRequest">
> 		<wsdl:part element="osesb:calcTotal" name="parameters" />
> 	</wsdl:message>
> 	<!-- order confirmation message -->
> 	<wsdl:message name="orderCalcTotalResponse">
> 		<wsdl:part element="osesb:orderCofirmation" name="parameters" />
> 	</wsdl:message>
> 	
> 	<!-- order Message for further processing in the ESB -->
> 	<wsdl:message name="placeOrderRequest">
> 		<wsdl:part element="osesb:order" name="parameters" />
> 	</wsdl:message>
> 	
> 	
> 	<wsdl:portType name="COSPortType">
> 		<wsdl:operation name="orderCalcTotal">
> 			<wsdl:input message="osesb:orderCalcTotalRequest"/>
> 			<wsdl:output message="osesb:orderCalcTotalResponse"/>
> 		</wsdl:operation>
> 		<wsdl:operation name="placeOrder">
> 			<wsdl:input message="osesb:placeOrderRequest"/>
>         </wsdl:operation>
> 	</wsdl:portType>
> 	
> 	<wsdl:binding name="COSSoapBinding" type="osesb:COSPortType">
> 		<soap:binding style="document"
> 			transport="http://schemas.xmlsoap.org/soap/http" />
> 		
> 		<wsdl:operation name="orderCalcTotal">
> 			<soap:operation soapAction="http://ps.com/COS/orderCalcTotal" />
> 			<wsdl:input>
> 				<soap:body use="literal" />
> 			</wsdl:input>
> 			<wsdl:output>
> 				<soap:body use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
> 		
> 		<wsdl:operation name="placeOrder">
> 			<soap:operation soapAction="http://ps.com/COS/placeOrder"/>
> 			<wsdl:input>
> 				<soap:body use="literal" />
> 			</wsdl:input>
> 		</wsdl:operation>
> 		
> 	</wsdl:binding>
> 	
> 	<wsdl:service name="COSService">
> 		<wsdl:port binding="osesb:COSSoapBinding" name="COSSoap">
> 			<soap:address location="http://localhost:8080/services/cos" />
> 		</wsdl:port>
> 	</wsdl:service>
> </wsdl:definitions>
> 
> ---------WSDL END--------------------------------------------------
> 
> ---------cxf-bc configuraton xbean
> snippet--------------------------------------------------
> 
> 	
> 	<cxfbc:consumer wsdl="classpath:COS.wsdl" 
> 		service="cos:COSService"
> 		interfaceName="cos:COSPortType"
> 		targetEndpoint="COSSoap"
> 		targetService="cos:COSService" 
> 		targetInterface="cos:COSPortType" />
> 		
> 
> ---------cxf-bc configuraton xbean
> END--------------------------------------------------
> 
> 
> ---------cxf-se configuraton xbean snippet
> --------------------------------------------------
> ´
>   <bean id="COSServiceImpl"
> class="com.ps.component.CustomerOrderServiceImpl" init-method="init"/>
> 
>   <classpath>
>     <location>.</location>
>   </classpath>
> 
>   <cxfse:endpoint>
>      <cxfse:pojo>
>        <bean class="com.ps.cos.COSPortTypeImpl">
>         <property name="delegate" ref="COSServiceImpl"/>
>       </bean>
>     </cxfse:pojo>
>   </cxfse:endpoint>
> ---------cxf-se configuraton xbean
> END--------------------------------------------------
> 
> 
> 
> ---------Jms configuraton xbean snippet
> --------------------------------------------------
> 	<jms:provider service="cos:COSServiceProvider"
> endpoint="COSServiceProvider"
> 		destinationName="order.input" connectionFactory="#connectionFactory" />
> 
> 	<jms:consumer service="esb:simpleConsumer" endpoint="simpleEndpoint"
> 		targetService="esb:errorHandler" destinationName="order.input"
> 		connectionFactory="#connectionFactory" />
> 	<bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
> 		<property name="brokerURL" value="tcp://localhost:61616" />
> 	</bean>
> 
> ---------Jms configuraton xbean snippet
> --------------------------------------------------
> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://www.nabble.com/CXF---%3E-JMS-tp21608439p21614883.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.