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 Red Hat JBoss Enterprise Application Platform. 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 |
|---|---|
|
This project contains the EJBs that are deployed to the server. |
|
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 Red Hat JBoss Enterprise Application Platform 7.4 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 the EAP_HOME and QUICKSTART_HOME Variables
In the following instructions, replace EAP_HOME with the actual path to your JBoss EAP installation. The installation path is described in detail here: Use of EAP_HOME and JBOSS_HOME Variables.
When you see the replaceable variable QUICKSTART_HOME, replace it with the path to the root directory of all of the quickstarts.
Start the JBoss EAP Standalone Server
-
Open a terminal and navigate to the root of the JBoss EAP directory.
-
Start the JBoss EAP server with the default profile by typing the following command.
$ EAP_HOME/bin/standalone.shNoteFor Windows, use the EAP_HOME\bin\standalone.batscript.
Build and Deploy the Quickstart
-
Make sure you start the JBoss EAP server as described above.
-
Open a terminal and navigate to the root directory of this quickstart.
-
Type the following command to build the artifacts.
$ mvn clean install wildfly:deploy
This deploys the ejb-asynchronous/target/ejb-asynchronous.jar to the running instance of the server.
You should see a message in the server log indicating that the archive deployed successfully.
Access the Application
-
Open a terminal and navigate to the root directory of this quickstart.
-
Type the following command to start the client.
$ cd client $ mvn exec:exec -
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] -
Check the server log. There should be two
INFOlog messages for thefireAndForgetinvocation.First, you should see the following message.
'fireAndForget' Will wait for 15000msThe second message appears after the client is finished, approximately 15 seconds later.
action 'fireAndForget' finished
Undeploy the Quickstart
When you are finished testing the quickstart, follow these steps to undeploy the archive.
-
Make sure you start the JBoss EAP server as described above.
-
Open a terminal and navigate to the root directory of this quickstart.
-
Type this command to undeploy the archive:
$ mvn wildfly:undeploy
Run the Quickstart in Red Hat CodeReady Studio or Eclipse
You can also start the server and deploy the quickstarts or run the Arquillian tests in Red Hat CodeReady Studio or from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see Use Red Hat CodeReady Studio or Eclipse to Run the Quickstarts.
This quickstart consists of multiple projects, so it deploys and runs differently in Red Hat CodeReady Studio than the other quickstarts.
-
Install the required Maven artifacts and deploy the asynchronous EJB quickstart project.
-
Right-click on the ejb-asynchronous-ejb project and choose Run As → Maven Install.
-
Right-click on the ejb-asynchronous-ejb project and choose Run As → Run on Server.
-
-
Build and run the client side of the quickstart project.
-
Right-click on the ejb-asynchronous-client project and choose Run As → Java 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.
-
-
To undeploy the project, right-click on the ejb-asynchronous-ejb project and choose Run As → Maven build. Enter
wildfly:undeployfor 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
JBoss EAP for OpenShift Incompatibility
This quickstart is not compatible with JBoss EAP for OpenShift or JBoss EAP for OpenShift Online templates.