introdução ao jboss fuse 6.x: criação e implantação de um...

Download Introdução ao JBoss Fuse 6.x: criação e implantação de um serviço CXF

If you can't read please download the document

Post on 18-Aug-2015

95 views

Category:

Software

3 download

Embed Size (px)

TRANSCRIPT

  1. 1. Red Hat JBoss Fuse: conceitos bsicos para desenvolvedores Rafael T. C. Soares Arquiteto de Solues, Red Hat Janeiro, 2015
  2. 2. 6 ADD NAME (View > Master > Slide master) J uso Apache Camel em minha aplicao! Camel um Framework de Integrao, no um ESB. Implementa os principais EIPs Oferece mecanismos para: Validao Enriquecimento (tratamento) Transformao Rotamento de mensagens
  3. 3. 7 ADD NAME (View > Master > Slide master) Por que JBoss Fuse? Quando seu projeto de integrao se torna complexo... Onde implantar minhas integraes? Como escalar e garantir alta disponibilidade? Como versionar e atualizar minha aplicao?
  4. 4. 8 ADD NAME (View > Master > Slide master) Por que JBoss Fuse Quando seu projeto de integrao se torna complexo... Preciso de um meio para realizar debug e o trace de mensagens em minhas integraes... Preciso implementar comunicao assncrona por meio de mensageria... etc
  5. 5. 9 ADD NAME (View > Master > Slide master) Por que JBoss Fuse Quando seu projeto de integrao se torna complexo... Preciso de suporte para implantao em larga escala... Como atualizar a aplicao sem afetar o ambiente inteiro? Quero implantar minha integrao em um container leve e flexivel!
  6. 6. 10 Red Hat JBoss Fuse Red Hat JBoss Fuse Container: arquitetura
  7. 7. 11 Red Hat JBoss Fuse JBoss Fuse The Big Picture Tooling Frameworks Containers Message Broker Service Bus Monitoring/Operation
  8. 8. 12 Red Hat JBoss Fuse JBoss Fuse The Big Picture Soluo composta por vrios Projetos Open Source JBoss Fuse Apache CXF Fuse Fabric Apache Camel Apache ServiceMix Apache ActiveMQ Apache Karaf
  9. 9. 13 Red Hat JBoss Fuse JBoss Fuse Container Suporta vrios tipos de deployment
  10. 10. 14 Red Hat JBoss Fuse Modelo de Desenvolvimento
  11. 11. 15 ADD NAME (View > Master > Slide master) Modelo de Desenvolvimento Linguagem de programao JavaSE 1.6 Vrias linguages dinmicas como DSL Scala JS Groovy Injeo de Dependncia DI Spring Blueprint (OSGI) Construo e gesto de dependncias Apache Maven
  12. 12. 16 ADD NAME (View > Master > Slide master) Ambiente JavaSE 1.6 ou > Apache Maven 3 Red Hat JBoss Fuse IDE ECLIPSE plugin JBoss Developer Studio (JBDS)
  13. 13. 17 ADD NAME (View > Master > Slide master) Modelo de Desenvolvimento JBoss Fuse Project Metadados OSGI Bundle METAINF/MANIFEST.MF Fuse Application Bundle (FAB) METAINF/maven/groupId/artifactId/pom.xml Web ARchive WEBINF/web.xml
  14. 14. 18 ADD NAME (View > Master > Slide master) Maven: conceitos Ciclo de vida mvn Estrutura do projeto
  15. 15. 19 ADD NAME (View > Master > Slide master) Maven: conceitos Resources/Descriptors Spring ProjectDir/src/main/resources/METAINF/spring/ Blueprint XML ProjectDir/src/main/resources/OSGI INF/blueprint/ Packaging Fuse Application Bundle (Fuse JAR) Bundle (OSGI JAR) WAR (Web Archive)
  16. 16. 20 ADD NAME (View > Master > Slide master) Maven: conceitos Maven Coordinates groupdId:arctifactId:version Dentro do JBoss Fuse container mvn:groupid/artifactid/version Dependncias Escopo build, test e run time OSGI Bundle provided no tem efeito Fuse Application Bundle provided implantada separadamente (shared library)
  17. 17. 21 ADD NAME (View > Master > Slide master) Maven: conceitos Repositrios Local Repository /home//.m2/repository Remote Repository Online Maven Central Fuse Source Maven Repo JBoss Maven Central etc System Repository (acessado apenas pelo Fuse em runtime) $FUSE_HOME/system
  18. 18. 22 ADD NAME (View > Master > Slide master) Maven: conceitos Repositrios Remotos Build Time /home//.m2/settings.xml Run Time $FUSE_HOME/etc/org.ops4j.pax.url.mvn.cfg org.ops4j.pax.url.mvn.repositories= http://my.corporate.nexus.com/nexus/content/groups/public@snapshots http://repo1.maven.org/maven2@id=maven.central.repo, https://repo.fusesource.com/nexus/content/repositories/releases@id=fusesource.release.repo, https://repo.fusesource.com/nexus/content/groups/ea@id=fusesource.ea.repo, http://svn.apache.org/repos/asf/servicemix/m2repo@id=servicemix.repo, http://repository.springsource.com/maven/bundles/release@id=springsource.release.repo, http://repository.springsource.com/maven/bundles/external@id=springsource.external.repo, https://oss.sonatype.org/content/groups/scalatools@id=scala.repo
  19. 19. 23 ADD NAME (View > Master > Slide master) Injeo de Dependncia Frameworks Suportados Spring XML Blueprint XML OSGI Spec (osgi.org) Similiar ao Spring. Antigo Spring DM (implementao da spec OSGI). Mais leve Resolve dependncias automaticamente em runtime
  20. 20. 24 ADD NAME (View > Master > Slide master) Injeo de Dependncia Spring XML Injeo de dependncia POJO Beans Configurao Camel CXF ActiveMQ OSGI toolkit OSGI Services (OSGI Compendium) Containers Services Persistence Security Transactions
  21. 21. 25 ADD NAME (View > Master > Slide master) Injeo de Dependncia Spring XML Descritor /src/main/resources/META-INF/spring/*.xml
  22. 22. 26 ADD NAME (View > Master > Slide master) Injeo de Dependncia Blueprint XML Injeo de dependncia Mais leve Especfico para containers OSGI Configurao Camel CXF ActiveMQ OSGI toolkit OSGI Services (OSGI Compendium) Containers Services Persistence Security Transactions
  23. 23. 27 ADD NAME (View > Master > Slide master) Injeo de Dependncia Blueprint XML Descritor /src/main/resources/OSGI-INF/blueprint/*.xml
  24. 24. 28 Red Hat JBoss Fuse Apache CXF Web Service Demo: WS Code First Approach
  25. 25. 29 Red Hat JBoss Fuse Maven Fuse Source Repository
  26. 26. 30 Red Hat JBoss Fuse Gerando o projeto Maven Maven archetype Maven Project $mvnarchetype:generate >DarchetypeGroupId=org.apache.servicemix.tooling >DarchetypeArtifactId=servicemixcxfcodefirstosgibundle >DarchetypeVersion=2012.01.0.redhat60024 >DgroupId=org.fusesource.example >DartifactId=cxfbasic >Dversion=1.0SNAPSHOT
  27. 27. 31 Red Hat JBoss Fuse Spring XML Configuration Build cdcxfbasic mvninstall
  28. 28. 32 Red Hat JBoss Fuse JBoss Fuse: tipos de instalao Minimal: Apache Karaf Apache Camel core selected Apache Camel components Medium: + Apache ActiveMQ + Fuse Management Console (hawtio) Full: + Apache CXF + JBI components
  29. 29. 33 Red Hat JBoss Fuse JBoss Fuse: instalao express unzipjbossfusefull6.1.0.redhat379.zip cdjbossfuse6.1.0.redhat379/ vimetc/users.properties cdbin/ ./fuse * Inicia o Fuse no modo standalone #Allusersspecifiedinthisfile,willbeuploadedtothefabricregistryandwill #beavailabletoallcontainersthatjointhefabric. #Thepasswordofthefirstuserinthefilewillalsobeusedasaregistry(zookeeper)password #unlessapasswordisexplicitlyspecified. admin=admin,admin
  30. 30. 34 Red Hat JBoss Fuse JBoss Fuse Shell
  31. 31. 35 Red Hat JBoss Fuse Deploy do WS JBossFuse:karaf@root>install mvn:org.fusesource.example/cxfbasic/1.0SNAPSHOT BundleID:251 JBossFuse:karaf@root>start251 JBossFuse:karaf@root>list [251][Active][][Started][60]ApacheServiceMix::CXF CodeFirstOSGiBundle(1.0.0.SNAPSHOT) obs: por padro o Fuse acessa o repositrio local do Maven (~/.m2/repository) para baixar um artefato. Caso necessrio possvel configurar um repositrio remoto no arquivo de configurao: $FUSE_HOME/etc/org.ops4j.pax.url.mvn.cfg atravs da propriedade org.ops4j.pax.url.mvn.repositories
  32. 32. 36 Red Hat JBoss Fuse Localizao de dependncias em runtime
  33. 33. 37 Red Hat JBoss Fuse Testando o Servio WS Endpoint http://localhost:8181/cxf/PersonServiceCF WSClient cdcxfbasic mvnPclient INFO:CreatingService {http://example.fusesource.org/}PersonServicefromclassorg.fusesource.example.Person InvokinggetPerson... getPerson._getPerson_personId=Guillaume getPerson._getPerson_ssn=0000000000 getPerson._getPerson_name=Guillaume
  34. 34. 38 Red Hat JBoss Fuse Camel Route Demo: Http Bridge
  35. 35. 39 Red Hat JBoss Fuse Gerando o projeto Maven Maven archetype Maven Project mvnarchetype:generate DarchetypeGroupId=org.apache.camel.archetypes DarchetypeArtifactId=camelarchetypeblueprint DarchetypeVersion=2.10.0.redhat60024 DgroupId=org.fusesource.example DartifactId=camelbasic Dversion=1.0SNAPSHOT
  36. 36. 40 Red Hat JBoss Fuse Blueprint XML Configuration Build cdcamelbasic mvninstall 5000
  37. 37. 41 Red Hat JBoss Fuse Build Desabilitar Teste unitrio (gerado pelo archetype) #comentar@Testdaclasse vimsrc/test/java/org/fusesource/example/RouteTest.java Adicionar dependencia do componente cameljetty vimpom.xml Build cdcamelbasic mvninstall org.apache.camel cameljetty 2.10.0.redhat60024
  38. 38. 42 Red Hat JBoss Fuse Deploy do WS JBossFuse:karaf@root>install mvn:org.fusesource.example/camelbasic/1.0SNAPSHOT BundleID:252 JBossFuse:karaf@root>start252 JBossFuse:karaf@root>list [252][Active][][Started][60]ACamelBlueprintRoute (1.0.0.SNAPSHOT)(1.0.0.SNAPSHOT)
  39. 39. 43 Red Hat JBoss Fuse Testando o Servio WSClient cd../cxfbasic mvnPclient Dexec.args="http://localhost:8282/cxf/PersonServiceCF" INFO:CreatingService{http://example.fusesource.org/}PersonServicefrom classorg.fusesource.example.Person InvokinggetPerson... Aps5seg... getPerson._getPerson_personId=Guillaume getPerson._getPerson_ssn=0000000000 getPerson._getPerson_name=Guillaume
  40. 40. 44 Red Hat JBoss Fuse Agrupando projetos com Maven
  41. 41. 45 Red Hat JBoss Fuse Agregao de projetos no Maven Maven Aggregate POM cdgetstarted/ vimpom.xml org.fusesource.example getstarted 1.0SNAPSHOT pom 4.0.0 GettingStarted::AggregatePOM GettingStartedexample cxfbasic camelbasic Build mvninstall
  42. 42. 46 Red Hat JBoss Fuse Definind

View more