Red Hat DocumentationFuse ESBToggle FramesPrintFeedback

A service unit project

Overview

Each service unit in the service assembly must be its own project. These projects are placed at the same level as the service assembly project. The contents of a service unit's project depends on the component at which the service unit is targeted. At the minimum, a service unit project contains a POM and an XML configuration file.

Seeding a project using a Maven artifact

Fuse ESB provides Maven artifacts for a number of service unit types. They can be used to seed a project with the smx-arch command. As shown in Example 26, the smx-arch command takes three arguments. The groupId value and the artifactId values correspond to the project's group ID and artifact ID.

Example 26. Maven archetype command for service units

smx-arch su suArchetypeName ["-DgroupId=my.group.id"] ["-DartifactId=my.artifact.id"]


Important

The double quotes(") are required when using the -DgroupId argument and the -DartifactId argument.

The suArchetypeName specifies the type of service unit to seed. Table 12 lists the possible values and describes what type of project is seeded.

Table 12. Service unit archetypes

NameDescription
camelCreates a project for using the Fuse Mediation Router service engine
cxf-seCreates a project for developing a Java-first service using the Fuse Service Framework service engine
cxf-se-wsdl-firstCreates a project for developing a WSDL-first service using the Fuse Service Framework service engine
cxf-bcCreates an endpoint project targeted at the Fuse Service Framework binding component
http-consumerCreates a consumer endpoint project targeted at the HTTP binding component
http-providerCreates a provider endpoint project targeted at the HTTP binding component
jms-consumerCreates a consumer endpoint project targeted at the JMS binding component (see Using the JMS Binding Component)
jms-providerCreates a provider endpoint project targeted at the JMS binding component (see Using the JMS Binding Component)
file-pollerCreates a polling (consumer) endpoint project targeted at the file binding component (see Using Poller Endpoints)
file-senderCreates a sender (provider) endpoint project targeted at the file binding component (see Using Sender Endpoints)
ftp-pollerCreates a polling (consumer) endpoint project targeted at the FTP binding component
ftp-senderCreates a sender (provider) endpoint project targeted at the FTP binding component
jsr181-annotatedCreates a project for developing an annotated Java service to be run by the JSR181 service engine [a]
jsr181-wsdl-firstCreates a project for developing a WSDL generated Java service to be run by the JSR181 service engine [a]
saxon-xqueryCreates a project for executing xquery statements using the Saxon service engine
saxon-xsltCreates a project for executing XSLT scripts using the Saxon service engine
eipCreates a project for using the EIP service engine. [b]
lwcontainerCreates a project for deploying functionality into the lightweight container [c]
beanCreates a project for deploying a POJO to be executed by the bean service engine
odeCreate a project for deploying a BPEL process into the ODE service engine

[a] The JSR181 has been deprecated. The Fuse Service Framework service engine has superseded it.

[b] The EIP service engine has been deprecated. The Fuse Mediation Router service engine has superseded it.

[c] The lightweight container has been deprecated.


Contents of a project

The contents of your service unit project change from service unit to service unit. Different components require different configuration. Some components, such as the Fuse Service Framework service engine, require that you include Java classes.

At a minimum, a service unit project will contain two things:

  • a POM file that configures the JBI plug-in to create a service unit

  • an XML configuration file stored in src/main/resources

    For many of the components, the XML configuration file is called xbean.xml. The Fuse Mediation Router component uses a file called camel-context.xml.

Configuring the Maven plug-in

You configure the Maven plug-in to package the results of the project build as a service unit by changing the value of the project's packaging element to jbi-service-unit as shown in Example 27.

Example 27. Configuring the maven plug-in to build a service unit

<project ...>
  <modelVersion>4.0.0</modelVersion>

  ...
  <groupId>com.widgets.demo.cxf-wsdl-first</groupId>
  <artifactId>cxfse-wsdl-first-su</artifactId>
  <name>CXF WSDL Fisrt Demo :: SE Service Unit</name>
  <packaging>jbi-service-unit</packaging>
  ...
</project>

Specifying the target components

To correctly fill in the metadata required for packaging a service unit, the Maven plug-in must be told what component (or components) the service unit is targeting. If your service unit only has a single component dependency, you can specify it in one of two ways:

  • List the targeted component as a dependency

  • Add a componentName property specifying the targeted component

If your service unit has more than one component dependency, you must configure the project as follows:

  1. Add a componentName property specifying the targeted component.

  2. Add the remaining components to the list dependencies.

Example 28 shows the configuration for a service unit targeting the Fuse Service Framework binding component.

Example 28. Specifying the target components for a service unit

...
<dependencies>
  <dependency>
    <groupId>org.apache.servicemix</groupId>
    <artifactId>servicemix-cxf-bc</artifactId>
    <version>3.3.1.0-fuse</version>[1]
  </dependency>
>/dependencies>
...

The advantage of using the Maven dependency mechanism is that it allows Maven to verify if the targeted component is deployed in the container. If one of the components is not deployed, Fuse ESB will not hold off deploying the service unit until all of the required components are deployed.

Tip

Typically, a message identifying the missing component(s) is written to the log.

If your service unit's targeted component is not available as a Maven artifact, you can specify the targeted component using the componentName element. This element is added to the standard Maven properties block and it specifies the name of a targeted component, as specified in Example 29.

Example 29. Specifying a target component for a service unit

...
<properties>
  <componentName>servicemix-bean</componentName>
</properties>
...

When you use the componentName element, Maven does not check to see if the component is installed, nor does it download the required component.

Example

Example 30 shows the POM file for a project that is building a service unit targeted to the Fuse Service Framework binding component.

Example 30. POM file for a service unit project

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent> 1
        <groupId>com.widgets.demo</groupId>
        <artifactId>cxf-wsdl-first</artifactId>
        <version>1.0</version>
    </parent>

  <groupId>com.widgets.demo.cxf-wsdl-first</groupId>
  <artifactId>cxfse-wsdl-first-su</artifactId>
  <name>CXF WSDL Fisrt Demo :: SE Service Unit</name>
  <packaging>jbi-service-unit</packaging> 2

  <dependencies> 3
    <dependency>
      <groupId>org.apache.servicemix</groupId>
      <artifactId>servicemix-cxf-bc</artifactId>
      <version>3.3.1.0-fuse</version>
    </dependency>
  >/dependencies>

  <build>
    <plugins>
      <plugin> 4
        <groupId>org.apache.servicemix.tooling</groupId>
        <artifactId>jbi-maven-plugin</artifactId>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
</project>

The POM file in Example 30 does the following:

1

Specifies that it is a part of the top-level project shown in Example C.2

2

Specifies that this project builds a service unit

3

Specifies that the service unit targets the Fuse Service Framework binding component

4

Specifies to use the Fuse ESB Maven plug-in



[1] You replace this with the version of Fuse Service Framework you are using.

Comments powered by Disqus