Más contenido relacionado La actualidad más candente (19) Similar a Devclub Servicemix Jevgeni Holodkov 23 04 09 (20) Devclub Servicemix Jevgeni Holodkov 23 04 095. Servicemix глазами разработчика
• XML • Java
<beans xmlns:jms=quot;http://servicemix.apache.org/jms/1.0quot; public class InsuranceJMSMarshaler extends DefaultConsumerMarshaler {
xmlns:esb=quot;http://esbinaction.com/insurancequot;>
<classpath> protected void populateMessage(Message message,
<location>.</location> NormalizedMessage normalizedMessage) throws Exception {
...... if (message instanceof ObjectMessage) {
<location>wstx-asl.jar</location> ObjectMessage objectMessage = (ObjectMessage) message;
<location>xpp3.jar</location> Object payload = objectMessage.getObject();
</classpath> Source source = JiBXUtil.marshalDocument(payload, quot;UTF-8quot;);
<jms:consumer service=quot;esb:insuranceReceiverquot; normalizedMessage.setContent(source);
endpoint=quot;jmsEndpoint“ targetService=quot;esb:insuranceDSLRouterquot; } else {
destinationName=quot;insurance.in“ throw new UnsupportedOperationException(quot;JMS message is not a
connectionFactory=quot;#connectionFactoryquot; ObjectMessagequot;);
marshaler=quot;#InsuranceJMSMarshalerquot;/> }
<bean id=quot;InsuranceJMSMarshalerquot; }
class=quot;esb.dzone.servicemix.util.InsuranceJMSMarshalerquot;/> }
<bean id=quot;connectionFactoryquot;
class=quot;org.apache.activemq.ActiveMQConnectionFactoryquot;>
<property name=quot;brokerURLquot; value=quot;tcp://localhost:61616quot; />
</bean>
</beans>
6. Mvn генерирует/управляет кодом
mvn archetype:create
-DarchetypeGroupId=org.apache.servicemix.tooling
-DarchetypeArtifactId=servicemix-http-provider-service-unit
-DgroupId=org.apache.servicemix.samples
-DartifactId=servicemix-example
11. Servicemix-http компонент
Consumer Provider
<http:endpoint <http:endpoint
service=quot;test:MyProviderServicequot;
service=quot;test:MyConsumerServicequot;
endpoint=quot;myProviderquot;
targetService=quot;test:MyServiceRoutin
role=quot;providerquot;
gSlipquot;
locationURI=quot;http://localhost:8080/
endpoint=quot;myConsumer“
MyServicequot;
role=quot;consumerquot;
soapVersion=quot;1.1quot; />
locationURI=quot;http://localhost:8192/S
ervice/quot;
defaultMep=quot;http://www.w3.org/20
04/08/wsdl/in-outquot;
soapVersion=quot;1.1quot;
wsdlResource=quot;classpath:MyService.
wsdlquot; />
13. Servicemix-EIP компонент
• Content-Based Router
• Message Filter
• Pipeline
• Static Recipient List
• Static Routing Slip
• Wire Tap
• XPath Splitter
• Aggregator
• Content Enricher
• Resequencer
• AsyncBridge
14. Паттерн content-based routing
<eip:content-based-router service=quot;test:routerquot; endpoint=quot;endpointquot;>
<eip:rules>
<eip:routing-rule>
<eip:predicate>
<eip:xpath-predicate xpath=quot;count(/test:echo) = 1quot;
namespaceContext=quot;#nsContextquot; />
</eip:predicate>
<eip:target>
<eip:exchange-target uri=quot;endpoint:http://test/pipeline/endpointquot; />
</eip:target>
</eip:routing-rule>
<eip:routing-rule>
<!-- there is no predicate, so this is the default destination -->
<eip:target>
<eip:exchange-target service=quot;test:recipientsquot; />
</eip:target>
</eip:routing-rule>
</eip:rules>
</eip:content-based-router>
16. Servicemix-camel компонент
<!-- the JBI container -->
<sm:container id=quot;jbiContainerquot; embedded=quot;truequot;>
<sm:components>
<ref id=quot;jbiquot; />
</sm:components>
<sm:endpoints>
<bean:endpoint service=quot;myproject:trackerquot; endpoint=quot;trackerquot; bean=quot;#trackerquot; />
</sm:endpoints>
</sm:container>
<bean id=quot;jbiquot; class=quot;org.apache.servicemix.camel.CamelJbiComponentquot; />
<camelContext id=quot;camelContextquot; useJmx=quot;truequot;
xmlns=quot;http://activemq.apache.org/camel/schema/springquot;>
<package>my.project.routeBuilders</package>
</camelContext>
19. Итог
• Активно развивающийся ESB с открытым
кодом
• Использует модульную JBI архитектуру
• Активно использует Maven 2
• Интегрирован со Spring-ом
• Содержит много готовых компонентов