Skip to content

Commit

Permalink
Updated for Fuse 7.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdreagan committed May 20, 2020
1 parent e9da40f commit 7839397
Show file tree
Hide file tree
Showing 41 changed files with 773 additions and 743 deletions.
75 changes: 39 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
NOTE: This project is not supported on JBoss Fuse version 6.3 or later
----------------------------------------------------------------------
# CXF LB/Proxy Example

CXF LB/Proxy Example
==================

Requirements
------------
## Requirements

* Apache Maven 3.x (http://maven.apache.org)
* JBoss Fuse 6.x (http://jboss.org/jbossfuse)

Building Example
----------------

From top level of example project directory, run

mvn clean install

Running in JBoss Fuse
---------------------

Start JBoss Fuse

<JBoss Fuse Home>/bin/fuse

From the JBoss Fuse console, enter the following to install the example application

features:addurl mvn:org.fusebyexample.examples/lbproxy-example/1.0.0-SNAPSHOT/xml/features
features:install lbproxy-example

To see what is happening within the JBoss Fuse server, you can continuously view the
log (tail) with the following command

log:tail

WS Test
-------------------

Use your favorite WS testing tool (ie. SoapUI) and point it to http://localhost:9090/greetingService?wsdl. Send in multiple requests and you should see it load balance/proxy to the different implementations.
Build the project source code

```
cd $PROJECT_ROOT
mvn clean install
```

## Running the example standalone (should be done in 3 separate terminal windows/tabs)

```
cd $PROJECT_ROOT/greeter-gateway
mvn spring-boot:run '-Dserver.port=8080'
cd $PROJECT_ROOT/greeter-english-impl
mvn spring-boot:run '-Dserver.port=9000'
cd $PROJECT_ROOT/greeter-german-impl
mvn spring-boot:run '-Dserver.port=9001'
cd $PROJECT_ROOT/greeter-spanish-impl
mvn spring-boot:run '-Dserver.port=9002'
```

## Running the example in OpenShift

```
oc new-project demo
cd $PROJECT_ROOT/greeter-gateway
mvn -P openshift clean install fabric8:deploy
cd $PROJECT_ROOT/greeter-english-impl
mvn -P openshift clean install fabric8:deploy
cd $PROJECT_ROOT/greeter-german-impl
mvn -P openshift clean install fabric8:deploy
cd $PROJECT_ROOT/greeter-spanish-impl
mvn -P openshift clean install fabric8:deploy
```

## Testing the code

Use your favorite WS testing tool (ie. SoapUI) and point it to http://localhost:8080/services/greeter.
24 changes: 1 addition & 23 deletions greeter-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.fusebyexample.examples</groupId>
<groupId>com.redhat.examples</groupId>
<artifactId>lbproxy-example</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>greeter-api</artifactId>

<packaging>bundle</packaging>

<name>LB/Proxy Example: Greeter API</name>

<build>
<plugins>

<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
Expand All @@ -56,26 +53,7 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
org.fusebyexample.examples.greeter
</Export-Package>
<Include-Resource>
org/fusebyexample/examples/greeter/Greeter.wsdl=${basedir}/src/main/resources/wsdl/Greeter.wsdl,
{maven-resources}
</Include-Resource>
</instructions>
</configuration>
</plugin>

</plugins>
</build>

</project>

8 changes: 4 additions & 4 deletions greeter-api/src/main/resources/wsdl/Greeter.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
~ limitations under the License.
-->
<wsdl:definitions name="GreeterService"
targetNamespace="http://examples.fusebyexample.org/greeter"
targetNamespace="http://examples.redhat.com/greeter"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://examples.fusebyexample.org/greeter"
xmlns:ns1="http://examples.fusebyexample.org/greeter"
xmlns:tns="http://examples.redhat.com/greeter"
xmlns:ns1="http://examples.redhat.com/greeter"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>
<xs:schema targetNamespace="http://examples.fusebyexample.org/greeter" xmlns="http://examples.fusebyexample.org/greeter" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:schema targetNamespace="http://examples.redhat.com/greeter" xmlns="http://examples.redhat.com/greeter" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="getGreeting" type="GetGreetingRequestType"/>
<xs:complexType name="GetGreetingRequestType">
<xs:sequence>
Expand Down
108 changes: 49 additions & 59 deletions greeter-english-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.fusebyexample.examples</groupId>
<groupId>com.redhat.examples</groupId>
<artifactId>lbproxy-example</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>greeter-english-impl</artifactId>

<packaging>bundle</packaging>

<name>LB/Proxy Example: Greeter English Implementation</name>

<dependencies>
Expand All @@ -40,78 +38,70 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.api</artifactId>
<scope>runtime</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-minimal</artifactId>
<scope>runtime</scope>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>fabric-cxf</artifactId>
<scope>runtime</scope>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf-starter</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/fabric8</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}/fabric8</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>!*</Export-Package>
<Import-Package>
io.fabric8.cxf,
*
</Import-Package>
</instructions>
</configuration>
<groupId>org.jboss.redhat-fuse</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<configuration>
<profileConfigDir>${project.build.directory}/fabric8</profileConfigDir>
<profile>${fabric8.profilePrefix}-english</profile>
<version>${fabric8.profileVersion}</version>
<parentProfiles>
feature-cxf
</parentProfiles>
<features>
cxf-jaxws
fabric-cxf
</features>
<featureRepos>
mvn:org.apache.cxf.karaf/apache-cxf/${version:cxf}/xml/features
mvn:io.fabric8/fabric8-karaf/${version:fabric}/xml/features
</featureRepos>
<bundles>
mvn:${project.groupId}/greeter-api/${project.version}
</bundles>
</configuration>
</plugin>
</plugins>
</build>

</project>
<profiles>
<profile>
<id>openshift</id>
<properties>
<fabric8.openshift.generateRoute>false</fabric8.openshift.generateRoute>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<executions>
<execution>
<id>fabric8</id>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
10 changes: 10 additions & 0 deletions greeter-english-impl/src/main/fabric8/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spec:
template:
spec:
containers:
- name: ${project.artifactId}
resources:
requests:
cpu: "0.5"
limits:
cpu: "4.0"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2016 Red Hat, Inc.
* <p>
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
*/
package com.redhat.examples.greeter.english;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

public static void main(String[] args) {

SpringApplication.run(Application.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2016 Red Hat, Inc.
* <p>
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
*/
package com.redhat.examples.greeter.english;

import org.apache.camel.builder.RouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class CamelConfiguration extends RouteBuilder {

private static final Logger log = LoggerFactory.getLogger(CamelConfiguration.class);

@Override
public void configure() throws Exception {

from("cxf:/greeter?serviceClass=com.redhat.examples.greeter.Greeter&loggingFeatureEnabled=true")
.setBody().simple("Hello ${body}!")
;
}
}
Loading

0 comments on commit 7839397

Please sign in to comment.