Skip to content

Latest commit

 

History

History

ejb-asynchronous

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

ejb-asynchronous: EJB with asynchronous methods

The ejb-asynchronous quickstart demonstrates the behavior of asynchronous EJB invocations by a deployed EJB and a remote client and how to handle errors.

What is it?

The ejb-asynchronous quickstart demonstrates the behavior of asynchronous EJB invocations in WildFly Application Server. The methods are invoked by both an EJB in the deployment and by a remote client. The quickstart also shows error handling if the asynchronous method invocation fails.

This example consists of the following Maven projects, each with a shared parent.

Project Description

ejb

This project contains the EJBs that are deployed to the server.

client

This project contains a remote EJB client.

The root pom.xml builds each of the subprojects in the above order and deploys the archive to the server.

System Requirements

The application this project produces is designed to be run on WildFly Application Server 12 or later.

All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.3.1 or later. See Configure Maven to Build and Deploy the Quickstarts to make sure you are configured correctly for testing the quickstarts.

Use of WILDFLY_HOME

In the following instructions, replace WILDFLY_HOME with the actual path to your WildFly installation. The installation path is described in detail here: Use of WILDFLY_HOME and JBOSS_HOME Variables.

Start the Server

  1. Open a terminal and navigate to the root of the WildFly directory.

  2. Start the WildFly server with the default standalone profile by typing the following command.

    $ WILDFLY_HOME/bin/standalone.sh
    Note
    For Windows, use the WILDFLY_HOME\bin\standalone.bat script.

Build and Deploy the Quickstart

  1. Make sure you have started the WildFly server as described above.

  2. Open a terminal and navigate to the root directory of this quickstart.

  3. Type this command to build and deploy the archive:

    $ mvn clean install wildfly:deploy
  4. This will deploy ejb/target/{artifactId}-ejb.jar to the running instance of the server.

    • In the server log, verify that the application deployed successfully.

Access the Application

  1. Open a terminal and navigate to the root directory of this quickstart.

  2. Type the following command to start the client.

    $ cd client
    $ mvn exec:exec
  3. Check the client output

    INFO: The server log should contain a message at (about) <date>, indicating that the call to the asynchronous bean completed.
    INFO: Got the async result as expected => returning at <date>, duration was 200ms
    INFO: Got the async result as expected after wait => returning at <date>, duration was 1500ms
    INFO: Catch the expected Exception of the asynchronous execution!
    INFO: Results of the parallel (server) processing : [returning at <date> duration was 5000ms, returning at <date>, duration was 3000ms]
  4. Check the server log. There should be two INFO log messages for the fireAndForget invocation.

    First, you should see the following message.

    'fireAndForget' Will wait for 15000ms

    The second message appears after the client is finished, approximately 15 seconds later.

    action 'fireAndForget' finished

Undeploy the Archive

  1. Make sure you have started the WildFly server as described above.

  2. Open a terminal and navigate to the root directory of this quickstart.

  3. When you are finished testing, type this command to undeploy the archive:

    $ mvn wildfly:undeploy

Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse

You can also start the server and deploy the quickstarts or run the Arquillian tests from Eclipse using JBoss tools. For general information about how to import a quickstart, add a WildFly server, and build and deploy a quickstart, see Use JBoss Developer Studio or Eclipse to Run the Quickstarts.

This quickstart consists of multiple projects, so it deploys and runs differently in JBoss Developer Studio than the other quickstarts.

  1. Install the required Maven artifacts and deploy the asynchronous EJB quickstart project.

    • Right-click on the {artifactId}-ejb project and choose Run AsMaven Install.

    • Right-click on the {artifactId}-ejb project and choose Run AsRun on Server.

  2. Build and run the client side of the quickstart project.

    • Right-click on the {artifactId}-client project and choose Run AsJava Application.

    • In the Select Java Application window, choose AsynchronousClient - org.jboss.as.quickstarts.ejb.asynchronous.client and click OK.

    • The client output displays in the Console window.

  3. To undeploy the project, right-click on the {artifactId}-ejb project and choose Run AsMaven build. Enter wildfly:undeploy for the Goals and click Run.

Debug the Application

If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.

$ mvn dependency:sources