  |
 | Launch Talend Runtime
|
First of all, launch your Talend Runtime container. To do so: Browse to the \Runtime_ESBSE\container\bin folder to access the container provided with Talend Open Studio for ESB. Double-click the trun.bat executable file. A commandline opens and the trun container starts.
Next
|
  |
 | Add a context variable to the provider Job
|
Go back to the Studio and in the Repository: Expand the Job Designs node and browse to the airportSoap_getAirportInformationByISOCountry Code provider Job you previously created or imported. Double-click it to open it on the Designer.
Next
|
  |
We will add a context variable to the provider Job. This way, the service will not work only in one fixed context, but the execution context of the service could be changed at any time. To do so: Click the Contexts view at the bottom of the Studio. Click the [+] button at the bottom of the Contexts view to add a new context to the Variables table. Rename this context: message. The Script code is automatically updated to context.message. Leave the other fields as they are.
Next
|
  |
Click the Values as table tab of the Context view to display the corresponding table. The name of the context you just created displays in the Name column. In the corresponding Default column, define the default value of the context to "Hello ".
Next
|
  |
Now, we will use this context variable in the provider Job of our service. To do so, in the Designer: Click tXMLMap to select it and click the Component view at the bottom of the Studio to display its properties. Click [...] next to the Map Editor field to open the component's editor. Note: you can also simply double-click tXMLMap on the Designer and its editor will open.
Next
|
  |
In the tXMLMap editor:Select the tns:getAirportInformationByISOCountryCodeResult node in the response table to the right to add the message context to the response that will be sent by the service. And click the Expression editor tab at the bottom of the editor.
Next
|
  |
In the Expression editor tab:Add the following code at the beginning of the field: context.message +, before the [row1.payload:/tns:getAirportInformationByISO CountryCode/tns:CountryAbbrviation] piece of code. Click Apply and OK to validate your changes and close the editor.
Next
|
  |
Press Ctrl+S to save you changes or click the Floppy disk button at the top left hand corner of the Studio. So, here, we have a Job which implements a service operation we would like to deploy in the container of Talend Runtime.
Next
|
  |
 | Export and deploy a service in Talend Runtime
|
In the Repository:We will now export the service. To do so: Expand the Services node. Right-click the Airport item and select Export Service in the menu.
Next
|
  |
In the Export Service wizard:Click the Browse button and browse directly to the deploy folder of the Talend Runtime Container: \Runtime_ESBSE\container\deploy. The Service is exported as a kar file, which is a collection of bundles. So, we are treating a service as a service entity and exporting a service as an OSGi feature which contains multiple bundles packaged as a kar file. Click Finish.
Next
|
  |
In Talend Runtime:To check that the service has correctly been deployed, type in the following command: cxf:list-endpoints. The Airport service displays as Started at the /esb/AirportService Address.
Next
 | It might take up to a couple of minutes to export and deploy a service, so if your service does not display as started, please, wait a bit and try the cxf:list-endpoints command again.
|
|
  |
To check whether the service is well deployed, you can also go to the CXF service list located at: http://localhost:8040/services. In this page, our getAirportInformationByISOCountryCode service operation is listed and information like endpoint address and a link to the WSDL are provided.
Next
|
  |
If you clicked on the WSDL: {http://airportsoap.sopera.de}airport link from the previous page you will be redirected to the WSDL of the getAirportInformationByISOCountryCode service operation. Keep the URI of this WSDL for a later usage.
Next
|
  |
And we can also test it with our consumer Job. To do so: In the Repository:Expand the Job Designs node and double-click the AirportConsumer Job to open it on the Designer.
Next
|
  |
In the AirportConsumer Job:Update the tESBConsumer properties so that it accesses the new endpoint of the service as it is now deployed in Talend Runtime. To do so: Double-click the tESBConsumer component to display its corresponding Component view and set its properties. In the Component view:Click the [...] button next to the Service configuration field to open the tESBConsumer editor.
Next
|
  |
In the tESBConsumer editor:In the WSDL field, type in the URI of the WSDL between double quotes: "http://localhost:8040/services/esb/AirportService?wsdl". In the Port Name field, select airportSoap. In the Operation field, select getAirportInformationByISOCountryCode. Click OK to validate.
Next
|
  |
In the Component view of tESBConsumer:The Endpoint field is automatically filled in with the URI of the Airport service endpoint address: http://localhost:8040/services/esb/AirportService.
Next
|
  |
In the Designer:Press F6 to run the Job. The Job is automatically saved before being executed. The Run view displays at the bottom of the Studio and the console follows the execution. We can see that Hello FOO has been transformed into XML and sent to the consumer.
Next
|
  |
 | Change the context parameter of the deployed service
|
Now, in order to change the parameter value of our context, we can just stop our deployed service and we can do it by stopping the feature. In Talend Runtime:So, to stop the feature, type in the following command: features:uninstall Airport-feature. Press Enter. Note: to check if the service is stopped you can execute the cxf:list-endpoints command again and the service should not display this time.
Next
|
  |
Now, we can create a new configuration file holding the new parameters to use in our service. This way, the execution context of the service will be changed even after it has been deployed. This file should be named exactly the same as the service name: Airport.cfg and should be located in the \Runtime_ESBSE\container\etc folder of Talend Runtime Container.
Next
|
  |
This configuration file is a simple property file, so it should only contain properties and their values. Here, simply type in: message = Hello 123. Save the Airport.cfg file.
Next
|
  |
Now, go back to the Talend Runtime Container console again to install the feature again and thus restart the service. To do so, type in features:install Airport-feature. Press Enter.
Next
|
  |
Go back to the AirportConsumer Job in the Studio and press F6 to run it again. The Run view displays at the bottom of the Studio and the console follows the execution. The new context set Hello 123 FOO displays. This means that, thanks to the configuration mechanism of OSGi, we can configure the data services at any time, even after they have been deployed in Talend Runtime Container.
|