You are previewing WildFly Cookbook.
O'Reilly logo
WildFly Cookbook

Book Description

Over 90 hands-on recipes to configure, deploy, and manage Java-based applications using WildFly

In Detail

With the increasing demand for distributed systems for Java applications, WildFly offers a robust platform on which to deploy and manage your services. As a matter of fact, WildFly 9 is a fully certified Java EE 7 platform and provides remote management tools, such as the redesigned Admin Console and the new and powerful Command Line Interface (CLI).

With practical and accessible material, you will begin by learning to set up your WildFly runtime environment, and progress to selecting appropriate operational models, managing subsystems, and conquering the CLI. You will then walk through the different balancing and clustering techniques, simultaneously learning about role-based access control and then developing applications targeting WildFly and Docker.

What You Will Learn

  • Run WildFly in both standalone and domain operational modes

  • Adopt the right profile for your applications

  • Configure and manage your WildFly instances with the Admin Console

  • Utilize the CLI to deploy, configure, stop, and start services

  • Develop HA systems with Apache HTTPD, WildFly, and ModCluster

  • Assemble TCP or UDP WildFly clusters

  • Deploy your application to the cloud with OpenShift Online

  • Use Linux containers with Docker to ship your clean, tested, and ready-to-use WildFly environment

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. WildFly Cookbook
      1. Table of Contents
      2. WildFly Cookbook
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Errata
          2. Piracy
          3. Questions
      9. 1. Welcome to WildFly!
        1. Introduction
        2. Software prerequisites
          1. Getting ready
          2. How to do it…
          3. There's more…
        3. Downloading and installing WildFly
          1. Getting ready
          2. How to do it…
        4. Understanding WildFly's directory overview
          1. How to do it…
          2. How it works…
        5. Running WildFly in standalone mode
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Running WildFly in domain mode
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Running WildFly as a service
          1. How to do it…
      10. 2. Running WildFly in Standalone Mode
        1. Introduction
        2. Running WildFly from a custom configuration folder
          1. How to do it…
          2. How it works…
          3. There's more…
        3. Binding WildFly onto a custom port
          1. How to do it...
            1. Using the Web Console
            2. Using the CLI
          2. There's more…
        4. Binding WildFly onto a custom IP
          1. How to do it…
          2. How it works…
          3. There's more...
        5. Configuring multiple WildFly instances to run on the same machine with different ports
          1. Getting ready
          2. How to do it…
            1. Using jboss.http.port
            2. Using jboss.socket.binding.port-offset
          3. There's more...
        6. Configuring multiple WildFly instances to run on the same machine with different IPs
          1. Getting ready
          2. How to do it…
          3. There's more…
        7. Managing applications using the deployments folder
          1. Getting ready
          2. How to do it…
          3. How it works…
        8. Connecting to the CLI
          1. Getting ready
          2. How to do it…
          3. There's more…
        9. Checking the server-state via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
        10. Deploying an application via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        11. Undeploying an application via the CLI
          1. Getting ready
          2. How to do it…
          3. There's more…
        12. Executing commands in batch mode via the CLI
          1. Getting ready
          2. How to do it…
        13. Reloading a server configuration via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
        14. Shutting down and restarting an instance via the CLI
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        15. Suspending and resuming an instance via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
        16. Backing up your configuration file via the CLI
          1. Getting ready
          2. How to do it…
      11. 3. Running WildFly in Domain Mode
        1. Introduction
        2. Running domain mode
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
        3. Connecting the host controller to the domain controller
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Master
            2. Slaves
        4. Stopping and starting server groups via the Web Console
          1. Getting ready
          2. How to do it…
          3. There's more...
        5. Stopping and starting your server groups via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works...
        6. Stopping and starting your servers via the CLI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Deploying and undeploying an application to a specific server group via Web Console
          1. Getting ready
          2. How to do it…
        8. Deploying and undeploying an application to a specific server group via the CLI
          1. Getting ready
          2. How to do it…
          3. There's more...
        9. Checking server status via the CLI
          1. Getting ready
          2. How to do it…
      12. 4. Managing the Logging Subsystem with the CLI
        1. Introduction
          1. Domain mode
          2. Standalone mode
        2. Creating a file-handler logging
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating a periodic-rotating file-handler
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Creating a size-rotating file-handler
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Defining asynchronous handlers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Creating a syslog-handler
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Listing and reading log files
          1. Getting ready
          2. How to do it...
          3. There's more…
        8. Using a different logging implementation
          1. Getting ready
          2. How to do it…
          3. There is more…
          4. See also
      13. 5. Managing the Datasource Subsystems with the CLI
        1. Introduction
        2. Preparing a non JDBC-4 compliant driver
          1. Getting ready
          2. How to do it…
        3. Creating and removing a datasource
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Checking the datasource connection
          1. Getting ready
          2. How to do it...
        5. Reading the datasource's statistics
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
        6. Setting a connection pool
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Creating and removing XA-Datasource
          1. Getting ready
          2. How to do it…
          3. How it works…
      14. 6. Clustering WildFly
        1. Introduction
        2. Creating a cluster in standalone mode
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Creating separate clusters in standalone mode
          1. Getting ready
            1. Node-A1
            2. Node-A2
            3. Node-B1
            4. Node-B2
          2. How to do it…
          3. How it works...
        4. Creating a cluster in domain mode
          1. Getting ready
          2. How to do it...
            1. Master
            2. Host-1
          3. How it works...
          4. There's more…
          5. See also
        5. Creating separate clusters in domain mode
          1. Getting ready
          2. How to do it…
            1. Master
            2. Host-1
            3. Host-2
            4. Testing the clusters
              1. Master
              2. Host-1
              3. Host-2
            5. Re-testing the clusters
          3. How it works…
          4. See also
        6. Creating a cluster via TCP
          1. Getting ready
          2. How to do it...
            1. Node-1
            2. Node-2
            3. Testing the TCP cluster
          3. How it works…
        7. Testing the UDP protocol with the JGroups tool
          1. How to do it...
            1. Graphical test
            2. Shell test
      15. 7. Load Balancing WildFly
        1. Introduction
        2. Installing and configuring Apache HTTPD
          1. Getting ready
          2. How to do it...
          3. See also
        3. Installing and configuring mod_cluster for Apache
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Balancing WildFly using auto advertising – UDP
          1. Getting ready
          2. How to do it…
          3. How it works…
            1. Dissecting processes
            2. Dissecting communications
          4. There's more…
          5. See also
        5. Balancing WildFly using a list of available balancers – TCP
          1. Getting ready
          2. How to do it...
          3. How it works…
        6. Balancing using the HTTP connector instead of AJP
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Preserve WildFly workers while restarting Apache
          1. Getting ready
          2. How to do it…
        8. Balancing the same context for different applications
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. See also
        9. Rolling updates
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      16. 8. Commanding the CLI
        1. Introduction
        2. Invoking CLI commands
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
        3. Checking the WildFly version
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
        4. Checking WildFly operational mode
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more…
            1. curl
        5. Getting the OS version
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
        6. Getting the JVM version
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
            2. More about the runtime type
        7. Checking the JVM options
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
        8. Checking JVM memories – heap-size and all
          1. Getting ready
          2. How to do it…
            1. Heap
            2. Non-heap
            3. Metaspace or PermGen
            4. Eden
            5. Old
            6. Survivor
          3. How it works…
          4. There's more…
            1. Curl
        9. Checking the server status
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. curl
        10. Checking the JNDI tree view
          1. Getting ready
          2. How to do it…
          3. How it works…
        11. Invoking CLI commands declared in an external file
          1. Getting ready
          2. How to do it…
          3. How it works…
      17. 9. Conquering the CLI
        1. Introduction
        2. Invoking server stop, start, and reload
          1. Getting ready
          2. How to do it…
            1. Stop
            2. Start
            3. Restart
            4. Reload
          3. How it works…
          4. There's more…
            1. Curl
        3. Invoking server group stop, start, restart, and reload
          1. Getting ready
          2. How to do it…
            1. Stop
            2. Start
            3. Restart
            4. Reload
          3. How it works…
          4. There's more…
            1. Curl
        4. Creating a server group
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        5. Creating a server
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Curl
        6. Managing an application – deploy, undeploy
          1. Getting ready
          2. How to do it…
            1. Deploy
            2. Status
            3. Undeploy
          3. How it works…
            1. Deploy
            2. Status
            3. Undeploy
          4. There's more…
            1. Curl deployment
            2. Status
            3. Curl undeployment
      18. 10. Hardening the WildFly Communication
        1. Introduction
        2. Securing WildFly using HTTPS
          1. Getting ready
          2. How to do it…
            1. Standalone
            2. Domain
          3. How it works…
          4. There's more…
          5. See also…
        3. Securing a specific application using HTTPS
          1. Getting ready
          2. How to do it…
            1. Standalone
              1. Testing
            2. Domain
              1. Testing
          3. How it works…
          4. There's more…
          5. See also…
        4. Securing the WildFly console using HTTPS
          1. Getting ready
          2. How to do it…
            1. Standalone
              1. Testing
            2. Domain
              1. Testing
          3. How it works…
          4. There's more…
          5. See also
        5. Securing domain and host controller communication using HTTPS
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also…
      19. 11. Hardening the WildFly Configuration
        1. Introduction
        2. Delivering your configuration using property files
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Securing your configuration hashing passwords
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
        4. Securing and protecting passwords using a vault
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      20. 12. Role-based Access Control with WildFly
        1. Introduction
        2. Switching between simple and RBAC providers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Managing users, groups, and their role mapping
          1. Getting ready
          2. How to do it…
            1. Users
            2. Groups
          3. How it works…
        4. Setting a predefined role to all authenticated users
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Granting user access by server group or host – scoped roles
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Integrating with OpenLDAP
          1. Getting ready
          2. How to do it…
          3. How it works…
      21. 13. Messaging with WildFly
        1. Introduction
        2. Running the messaging system using HornetQ
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Sending and receiving messages to/from a JMS queue destination
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Clustering HornetQ using a shared store
          1. Getting ready
          2. How to do it…
            1. Testing
          3. How it works…
          4. See also
        5. Clustering HornetQ using message replication
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      22. 14. WildFly into the Cloud with OpenShift
        1. Introduction
        2. Registering to OpenShift Online
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Installing the WildFly cartridge for our first deployment
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Taking control of your WildFly server via SSH
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Deploying your code to OpenShift Online
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      23. 15. Using WildFly with Docker
        1. Introduction
        2. Setting up the Docker environment
          1. Getting ready
          2. How to do it…
          3. How it works…
        3. Running WildFly in Docker
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Logging WildFly outside Docker
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Running WildFly in domain mode in Docker using different Docker containers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There is more…
          5. See also
      24. Index