The ejb-asynchronous
quickstart demonstrates the behavior of asynchronous EJB invocations by a deployed EJB and a remote client and how to handle errors.
The ejb-asynchronous
quickstart demonstrates the behavior of asynchronous EJB invocations in {productNameFull}. 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.
-
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
INFO
log messages for thefireAndForget
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
../shared-doc/undeploy-the-quickstart.adoc ../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc
This quickstart consists of multiple projects, so it deploys and runs differently in {JBDSProductName} than the other quickstarts.
-
Install the required Maven artifacts and deploy the asynchronous EJB quickstart project.
-
Right-click on the {artifactId}-ejb project and choose Run As → Maven Install.
-
Right-click on the {artifactId}-ejb project and choose Run As → Run on Server.
-
-
Build and run the client side of the quickstart project.
-
Right-click on the {artifactId}-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 {artifactId}-ejb project and choose Run As → Maven build. Enter
wildfly:undeploy
for the Goals and click Run.