DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Hibernate Get vs. Load
  • Does the OCP Exam Still Make Sense?
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • Multi-Stream Joins With SQL
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Building Microservices With Wildfly Swarm

Building Microservices With Wildfly Swarm

See how easy it is to build and deploy microservices with lightweight Wildfly Swarm containers.

Vinod Pahuja user avatar by
Vinod Pahuja
·
Feb. 21, 20 · Tutorial
Like (11)
Save
Tweet
Share
24.02K Views

Join the DZone community and get the full member experience.

Join For Free

Wildfly Swarm is a lightweight container for deploying apps and services using various JEE specifications. It supports the full project lifecycle using its own Maven dependency management and builds plugin.

For initial development, we are leveraging a JAX-RS based microservice-starter application similar to implementation with[out] Spring Boot.

You may also like: Building Microservices Using Spring Boot and Docker — Part 1

More about the lifecycle is explained below.

Packaging

Wildfly Swarm provides its own Maven support to package the code and it's dependencies as an Uber jar, including the container itself. For this, you need to add the following build plugin.

Plain Text
 




x
14


 
1
<build>
2
  <plugins>
3
    <plugin>
4
      <groupId>org.wildfly.swarm</groupId>
5
      <artifactId>wildfly-swarm-plugin</artifactId>
6
      <version>2018.3.3</version>
7
      <executions>
8
        <execution>
9
          <goals><goal>package</goal></goals>
10
        </execution>
11
      </executions>
12
    </plugin>
13
  </plugins>
14
</build>



Deployment

Wildfly Swarm is an embeddable container that provides support for multiple deployment options. It can deploy web, JAXRS, and EJB containers. You can add a specific fraction for deploying only the required container.

Plain Text
 




xxxxxxxxxx
1


 
1
<dependency>
2
  <groupId>org.wildfly.swarm</groupId>
3
  <artifactId>jaxrs</artifactId>
4
  <version>2018.3.3</version>
5
</dependency>



Launcher

A Wildfly Swarm container can be launched using the standard as well as customer launchers.

Standard — Just run the following Maven goal on the project.

Plain Text
 




xxxxxxxxxx
1


 
1
mvn wildfly-swarm:run



Custom — Add an Application class to programmatically invoke and deploy containers.

Plain Text
 




xxxxxxxxxx
1


 
1
Swarm swarm = new Swarm();
2
swarm.start();
3
 
          
4
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
5
deployment.addClass(HelloWorldResource.class);
6
swarm.deploy(deployment);



Here we are using the ShrinkWrap API to programmatically create a deployable archive at runtime.

The complete example can found here at microservice-starter-wildflyswarm.


Further Reading

Migrate Standalone HornetQ Configuration to ActiveMQ Cluster

Monitoring Docker Swarm

Docker Tutorial: Play With Docker and Docker Swarm

Docker (software) WildFly microservice Plain text Spring Framework

Opinions expressed by DZone contributors are their own.

Trending

  • Hibernate Get vs. Load
  • Does the OCP Exam Still Make Sense?
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • Multi-Stream Joins With SQL

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: