Creating JBoss Fuse projects with Red Hat Code Ready Studio



In this lesson we will learn how to create a Red Hat Fuse project using JBoss Fuse tooling which is included in Red Hat Code Ready studio and to run a Fuse project within it.

Red Hat Code Ready studio is a development environment with superior support for your entire development lifecycle.

Start by downloading Red Hat Code Ready Studio: https://developers.redhat.com/products/codeready-studio/download

Once downloaded it, execute the JAR file:

java -jar codereadystudio-12.14.0.GA-installer-standalone.jar

The Red Hat Code Ready studio wizard will start. Just make sure you include the Fuse tooling in the installation:

jboss fuse tooling example

At the end of the installation, you can launch Red Hat Code Ready studio .

Creating your first Fuse project with Fuse Tooling

From the File Menu choose: File | New | Fuse Integration Project:

jboss fuse tooling code ready studio tutorial

Then select a Target Environment, for example a Standalone Spring Boot application:

jboss fuse tooling code ready studio tutorial

In the next UI click Finish and a simple log using Spring Boot application will be generated

Let's check the source code which has been added:

src
└── main
    ├── fabric8
    │   └── deployment.yml
    ├── java
    │   └── org
    │       └── mycompany
    │           └── Application.java
    └── resources
        ├── application.properties
        ├── logback.xml
        └── spring
            └── camel-context.xml

First of all, a spring-boot application Class that includes a Camel route builder to setup the Camel routes has been added:

@SpringBootApplication
@ImportResource({"classpath:spring/camel-context.xml"})
public class Application {

    // must have a main method spring-boot can run
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

The above classes, imports as a Resource the following camel-context.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd        http://camel.apache.org/schema/spring       https://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route id="simple-route">
            <from id="route-timer" uri="timer://foo?period=1000"/>
            <setBody id="route-setBody">
                <simple>Hello World from camel-context.xml</simple>
            </setBody>
            <log id="route-log" message=">>> ${body}"/>
        </route>
    </camelContext>
</beans>

The route can be designed/edited graphically thanks to the Fuse Tooling plugin:

jboss fuse tooling code ready studio tutorial

In order to run the application, just right-click on the Application Main class and choose "Run".

The following log will be displayed in the Console Panel:

11:07:47.820 [main] INFO  org.mycompany.Application - Started Application in 4.533 seconds (JVM running for 4.874)
11:07:48.787 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml
11:07:49.775 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml
11:07:50.775 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml

Running Spring Boot and Fuse as Container Image

As you can check from the pom.xml, the project includes the fabric8-maven-plugin:

  <plugin>
        <groupId>org.jboss.redhat-fuse</groupId>
        <artifactId>fabric8-maven-plugin</artifactId>
        <version>${fuse.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>resource</goal>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
   </plugin>

Before triggering the execution of the plugin, make sure Docker is started:

service docker start

Then from the shell you can run your project with:

mvn clean install spring-boot:run

The project will start, once that the container image of it has been created:

10:59:43.577 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml
10:59:44.577 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml
10:59:45.577 [Camel (MyCamel) thread #2 - timer://foo] INFO  simple-route - >>> Hello World from camel-context.xml

You can check that the project Container image is available as follows:

$ docker images
REPOSITORY                                             TAG                           IMAGE ID            CREATED             SIZE
mycompany/camel-ose-springboot-xml                     latest                        71483fb79b90        2 minutes ago       517 MB

 

FREE WildFly Application Server - JBoss - Quarkus - Drools Tutorials
Cookie Policy

Cookie Policy This website uses cookies that are necessary to its functioning and required to achieve the purposes illustrated in the privacy policy. By accepting this OR scrolling this page OR continuing to browse, you agree to our privacy policy.

© 2020 Your Company. All Rights Reserved. Designed By JoomShaper

Please publish modules in offcanvas position.