Red Hat

WildFly Swarm Initial Release

Happy Cinco De Mayo!

Crack open a cold adult beverage and start retooling your JavaEE skills towards microservices.

What is WildFly Swarm?

WildFly Swarm [1] is a new sidecar project supporting WildFly 9.x to enable deconstructing the WildFly AS and pasting just enough of it back together with your application to create a self-contained executable jar.

JAX-RS is a microservice?

In the simplest case, you make small adjustments to your existing Maven pom.xml that generates a WAR file and you’ll get another artifact with a name akin to myproject-1.0-swarm.jar.

Simply add the wildfly-swarm-plugin to your pom.xml:

<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>create</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Add a <dependency> block or two:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>wildfly-swarm-jaxrs</artifactId>
    <version>${version.wildfly-swarm}</version>
    <scope>provided</scope>
</dependency>

Build your project:

mvn package

And run that sucker:

java -jar ./target/myproject-1.0-swarm.jar

Can I get fancier?

You betcha!

Since WildFly Swarm is based upon WildFly 9.x, you have most of the power of WildFly available to you. This includes subsystems such as:

  • Undertow (Servlets)

  • JAX-RS

  • Naming/JNDI

  • Transactions

  • Messaging

  • Datasources

  • Logging

  • Weld (CDI)

  • JBoss MSC

  • Security

Additionally, if you want to provide your own main(…​) method to instantiate the Container, configure some of the subsystems, and perform whatever deployments you need, that’s possible also!

public class Main {

    public static void main(String[] args) throws Exception {
        Container container = new Container();

        container.subsystem(new MessagingFraction()
                        .server(
                                new MessagingServer()
                                        .enableInVmConnector()
                                        .topic("my-topic")
                                        .queue("my-queue")
                        )
        );

        // Start the container
        container.start();

        JaxRsDeployment appDeployment = new JaxRsDeployment();
        appDeployment.addResource(MyResource.class);

        // Deploy your JAX-RS app
        container.deploy(appDeployment);

        // Create an MSC deployment
        ServiceDeployment deployment = new ServiceDeployment();
        deployment.addService(new MyService("/jms/topic/my-topic" ) );

        // Deploy the services
        container.deploy( deployment );
    }
}

Can I use it in production?

We wouldn’t recommend it. We just released 1.0.0.Alpha1. It’s pretty new and we’re sure there’s some dark corners that we have not addressed.

If you come across any issues or desire any improvements, file an issue over at GitHub, and we’ll do our best to make you happy.

Do you have more examples?

What do I download?

There is no special download or installation instructions. Simply start using org.wildfly.swarm artifacts in your pom.xml, throw in the plugin and continue doing your builds. Everything is available through Maven Central.

Stay in Touch

You can keep up with the project through the WildFly HipChat room, @wildflyswarm on Twitter, or through GitHub Issues.


1. never to be called just "Swarm", because Legal

Bob McWhirter

Bob leads the Research & Prototyping group within Red Hat Middleware, typically mis-using other projects within the company. He plays the banjo.

Location:  Wytheville, VA

Occupation:  Director, R&P

Latest News

back to top