Talend ESB Development Guide
Total Page:16
File Type:pdf, Size:1020Kb
Talend ESB Development Guide 7.0.1 Talend ESB Adapted for v7.0.1. Supersedes previous releases. Publication date: April 13, 2018 Copyright © 2018 Talend Inc. All rights reserved. Copyleft This documentation is provided under the terms of the Creative Commons Public License (CCPL). For more information about what you can and cannot do with this documentation in accordance with the CCPL, please read: http://creativecommons.org/licenses/by-nc-sa/2.0/ This document may include documentation produced at The Apache Software Foundation which is licensed under The Apache License 2.0. Notices Talend and Talend ESB are trademarks of Talend, Inc. Apache CXF, CXF, Apache Karaf, Karaf, Apache Cellar, Cellar, Apache Camel, Camel, Apache Maven, Maven, Apache Archiva, Archiva, Apache Syncope, Syncope, Apache ActiveMQ, ActiveMQ, Apache Log4j, Log4j, Apache Felix, Felix, Apache ServiceMix, ServiceMix, Apache Ant, Ant, Apache Derby, Derby, Apache Tomcat, Tomcat, Apache ZooKeeper, ZooKeeper, Apache Jackrabbit, Jackrabbit, Apache Santuario, Santuario, Apache DS, DS, Apache Avro, Avro, Apache Abdera, Abdera, Apache Chemistry, Chemistry, Apache CouchDB, CouchDB, Apache Kafka, Kafka, Apache Lucene, Lucene, Apache MINA, MINA, Apache Velocity, Velocity, Apache FOP, FOP, Apache HBase, HBase, Apache Hadoop, Hadoop, Apache Shiro, Shiro, Apache Axiom, Axiom, Apache Neethi, Neethi, Apache WSS4J, WSS4J are trademarks of The Apache Foundation. Eclipse Equinox is a trademark of the Eclipse Foundation, Inc. SoapUI is a trademark of SmartBear Software. Hyperic is a trademark of VMware, Inc. Nagios is a trademark of Nagios Enterprises, LLC. All other brands, product names, company names, trademarks and service marks are the properties of their respective owners. This product includes software developed at AOP Alliance (Java/J2EE AOP standards), ASM, AntlR, Apache ActiveMQ, Apache Ant, Apache Avro, Apache Axiom, Apache Axis, Apache Axis 2, Apache Batik, Apache CXF, Apache Camel, Apache Chemistry, Apache Common Http Client, Apache Common Http Core, Apache Commons, Apache Commons Bcel, Apache Commons JxPath, Apache Commons Lang, Apache Derby Database Engine and Embedded JDBC Driver, Apache Geronimo, Apache Hadoop, Apache Hive, Apache HttpClient, Apache HttpComponents Client, Apache JAMES, Apache Log4j, Apache Lucene Core, Apache Neethi, Apache POI, Apache Pig, Apache Qpid-Jms, Apache Tomcat, Apache Velocity, Apache WSS4J, Apache WebServices Common Utilities, Apache Xml-RPC, Apache Zookeeper, Box Java SDK (V2), CSV Tools, DataStax Java Driver for Apache Cassandra, Ehcache, Ezmorph, Ganymed SSH-2 for Java, Google APIs Client Library for Java, Google Gson, Groovy, Guava: Google Core Libraries for Java, H2 Embedded Database and JDBC Driver, HsqlDB, Ini4j, JClouds, JLine, JSON, JSR 305: Annotations for Software Defect Detection in Java, JUnit, Jackson Java JSON-processor, Java API for RESTful Services, Jaxb, Jaxen, Jettison, Jetty, Joda-Time, Json Simple, MetaStuff, Mondrian, OpenSAML, Paraccel JDBC Driver, PostgreSQL JDBC Driver, Resty: A simple HTTP REST client for Java, Rocoto, SL4J: Simple Logging Facade for Java, SQLite JDBC Driver, Simple API for CSS, SshJ, StAX API, StAXON - JSON via StAX, Talend Camel Dependencies (Talend), The Castor Project, The Legion of the Bouncy Castle, W3C, Woden, Woodstox : High-performance XML processor, XML Pull Parser (XPP), Xalan-J, Xerces2, XmlBeans, XmlSchema Core, Xmlsec - Apache Santuario, Zip4J, atinject, dropbox- sdk-java: Java library for the Dropbox Core API, google-guice. Licensed under their respective license. Table of Contents Chapter 1. Development Environment Setup ................................................................... 1 1.1. Download Java Development Kit (JDK) ......................................................................... 2 1.2. Download Eclipse IDE for Java EE Developers .................................................................. 2 1.3. Download Tomcat 7.x (optional) ................................................................................ 2 1.4. Download Maven 3 ............................................................................................... 3 1.5. Install Maven2Eclipse (m2e) Plugin (optional) ................................................................. 4 1.6. Install soapUI Plugin (optional) .................................................................................. 5 Chapter 2. Web Services ............................................................................................... 6 2.1. Contract-first development ....................................................................................... 8 2.1.1. Project Structure . 8 2.1.2. Maven POM files . 9 2.1.3. Creating the WSDL . 14 2.1.4. Configuring Deployment Descriptors . 16 2.1.5. Creating the Web Service Provider (WSP) . 17 2.1.6. Deploying the WSP . 19 2.1.7. Running the SOAP Client . 20 2.2. Code-first development ......................................................................................... 20 2.2.1. CXF Maven Archetypes . 22 2.2.2. Adding OSGi Capabilities to a Web Service . 25 2.2.3. Making SOAP calls with soapUI . 27 2.3. REST Services .................................................................................................... 28 Chapter 3. Camel Routes Overview .............................................................................. 31 Chapter 4. Talend ESB Services Overview ..................................................................... 35 4.1. Service Locator ................................................................................................... 36 4.1.1. Using the Service Locator in non-OSGi environments . 36 4.1.2. Service interface . 36 4.1.3. Service implementation . 38 4.1.4. Service Consumer . 41 4.1.5. ZooKeeper usage . 43 4.1.6. Service Locator for RESTful services . 47 4.2. Service Activity Monitoring ..................................................................................... 48 4.2.1. Run the Monitoring Server . 48 4.2.2. Prepare the sample . 48 4.2.3. Test SAM Server . 51 iii Chapter 1. Development Environment Setup Welcome to Talend ESB! This document looks at best practices in developing with Talend ESB, in particular using Eclipse and Maven as development tools. While development with the Eclipse IDE is covered within this guide, note the Eclipse-based Talend Studio can also be used instead, as it already includes the development components we'll be configuring below. Different types of web services (JAX-WS and JAX-RS based) will be covered in Web Services, and then we'll explore Camel development in Camel Routes Overview. Finally, developing with Talend ESB specific services such as Service Activity Monitoring and the Service Locator is covered in Talend ESB Services Overview. In this chapter we'll look in detail at installing our Eclipse development environment along with associated tools for development of web services and Camel routes. Note, if you're already working with the pre-configured Talend Studio, this process can be skipped. The following sections in this chapter give details of the software needed. 1 Development Environment Setup 1.1. Download Java Development Kit (JDK) Either Java SE versions 6 or 7 are acceptable and can be obtained from: http://www.oracle.com/ technetwork/java/javase/downloads/index.html. As we'll be compiling source files, be sure to download the JDK and not the JRE version. 1.2. Download Eclipse IDE for Java EE Developers From the Eclipse download page obtain your operating system's version of Eclipse IDE for Java EE Developers. Juno is the most recent Eclipse version as the time of this writing, but if you already have the previous Helios or Indigo versions of Eclipse on your machine that should work fine as well. After extracting the application, double-clicking the Eclipse icon located in the Eclipse root directory should bring up the IDE; note your specific operating system's version may provide additional convenient options (menu items, desktop icons) for activating Eclipse. After installing, have Eclipse point to the JDK you downloaded in the previous step. This can be done by selecting menu item: Windows | Preferences and the corresponding Preferences Dialog, selecting Java | Installed JREs from the left-side menu tree. 1.3. Download Tomcat 7.x (optional) This guide will show you how to deploy CXF services and Camel routes using Talend ESB's Karaf- based Container. However for testing and debugging it can be helpful to be aware of how to deploy on the servlet container Apache Tomcat. Steps involved to deploy a Tomcat installation on your computer: • Download and uncompress the latest Tomcat release version from the Apache Tomcat site. • Create a $CATALINA_HOME operating system environment variable pointing to the base directory of Tomcat, and add the $CATALINA_HOME/bin directory to your system path so you can easily start Tomcat from any system folder. • You'll need to edit the $CATALINA_HOME/conf/tomcat-users.xml file to create an administrative user for deploying and undeploying web applications. Define two new roles, manager-script> and manager-gui and add them to either a new user or any existing user, e.g.: <tomcat-users> <role rolename="manager-script"/> <role rolename="manager-gui"/> <user username="tomcat" password="tomcat" roles="manager-script,manager-gui"/> ...other users and roles... </tomcat-users> Of course, for a production deployment you'll want to use a username and password different from the easy-to-guess ones above. 2 Development Environment Setup