Servicemix 3.х Сервисная шина ESB Евгений Холодков devclub.eu 23.04.09
Servicemix 3.хСервисная шина ESB
Евгений Холодков devclub.eu 23.04.09
Servicemix глазами клиентов
Servicemix глазами архитектора
Java Business Integration (JBI)
Servicemix глазами разработчика
• XML<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" xmlns:esb="http://esbinaction.com/insurance"> <classpath> <location>.</location> ...... <location>wstx-asl.jar</location> <location>xpp3.jar</location> </classpath> <jms:consumer service="esb:insuranceReceiver" endpoint="jmsEndpoint“ targetService="esb:insuranceDSLRouter" destinationName="insurance.in“
connectionFactory="#connectionFactory" marshaler="#InsuranceJMSMarshaler"/> <bean id="InsuranceJMSMarshaler" class="esb.dzone.servicemix.util.InsuranceJMSMarshaler"/> <bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616" /> </bean></beans>
• Javapublic class InsuranceJMSMarshaler extends DefaultConsumerMarshaler {
protected void populateMessage(Message message, NormalizedMessage normalizedMessage) throws Exception { if (message instanceof ObjectMessage) { ObjectMessage objectMessage = (ObjectMessage) message; Object payload = objectMessage.getObject(); Source source = JiBXUtil.marshalDocument(payload, "UTF-8"); normalizedMessage.setContent(source); } else { throw new UnsupportedOperationException("JMS message is not a
ObjectMessage"); } }}
Mvn генерирует/управляет кодом
mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-http-provider-service-unit -DgroupId=org.apache.servicemix.samples -DartifactId=servicemix-example
Бизнес-процесс (1/2)
Бизнес-процесс (2/2)
Процесс в servicemix-e
Еще один пример
Servicemix-http компонент
Consumer<http:endpoint service="test:MyConsumerService"
targetService="test:MyServiceRoutingSlip"
endpoint="myConsumer“ role="consumer"
locationURI="http://localhost:8192/Service/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" soapVersion="1.1" wsdlResource="classpath:MyService.wsdl" />
Provider<http:endpoint
service="test:MyProviderService" endpoint="myProvider" role="provider" locationURI="http://localhost:8080/MyService"
soapVersion="1.1" />
Servicemix-saxon компонент
<beans xmlns:saxon="http://servicemix.apache.org/saxon/1.0" xmlns:test="http://www.mycompany.com/1.0"> <saxon:xslt service="test:myTransform" endpoint="myEndpoint" resource="classpath:transform.xsl" />
</beans>
Servicemix-EIP компонент
• Content-Based Router• Message Filter• Pipeline• Static Recipient List• Static Routing Slip• Wire Tap• XPath Splitter• Aggregator• Content Enricher• Resequencer• AsyncBridge
Паттерн content-based routing<eip:content-based-router service="test:router" endpoint="endpoint"> <eip:rules> <eip:routing-rule> <eip:predicate> <eip:xpath-predicate xpath="count(/test:echo) = 1"
namespaceContext="#nsContext" /> </eip:predicate> <eip:target> <eip:exchange-target uri="endpoint:http://test/pipeline/endpoint" /> </eip:target> </eip:routing-rule> <eip:routing-rule> <!-- there is no predicate, so this is the default destination --> <eip:target> <eip:exchange-target service="test:recipients" /> </eip:target> </eip:routing-rule> </eip:rules></eip:content-based-router>
Паттерн routing-slip
<eip:static-routing-slip service="test:routingSlip" endpoint="endpoint"> <eip:targets> <eip:exchange-target service="test:transformRequest" /> <eip:exchange-target service="test:myProvider" /> <eip:exchange-target service="test: transformResponse" /> </eip:targets></eip:static-routing-slip>
Servicemix-camel компонент<!-- the JBI container --> <sm:container id="jbiContainer" embedded="true"> <sm:components> <ref id="jbi" /> </sm:components> <sm:endpoints> <bean:endpoint service="myproject:tracker" endpoint="tracker" bean="#tracker" /> </sm:endpoints> </sm:container>
<bean id="jbi" class="org.apache.servicemix.camel.CamelJbiComponent" />
<camelContext id="camelContext" useJmx="true" xmlns="http://activemq.apache.org/camel/schema/spring">
<package>my.project.routeBuilders</package> </camelContext>
Интеграционное тестирование
• Wire Tap
• SoapUI
Развертывание
• SA = jar файл• Standalone vs web application
Итог
• Активно развивающийся ESB с открытым кодом
• Использует модульную JBI архитектуру• Активно использует Maven 2• Интегрирован со Spring-ом• Содержит много готовых компонентов