Junos Space SDK > Developer Guides > Junos Space Application Developer Guide > Programming with the Junos Space SDK > Using the Junos Space SDK Plug-in > Using the EJB-REST Wizard

RESTifying Asynchronous APIs with the EJB-REST Wizard

The Junos Space SDK allows you to generate code for asynchronous APIs (also known as long running requests or LRRs) using the EJB-REST wizard. When the wizard recognizes an asynchronous API it creates the appropriate REST code. The wizard recognizes the APIs as asynchronous when the EJB method satisfies the following conditions:

  1. Returns object of type as net.juniper.jmp.cmp.jobManager.JobInfoTO
  2. Uses parameter of type net.juniper.jmp.ScheduleContext
  3. Uses the annotation type net.juniper.jmp.annotation.scheduler.Schedulable

Note: The @Schedulable annotation is optional.


The following EJB method is considered an asynchronous API because it meets all three required conditions:

public JobInfoTO runCountriesReport(ScheduleContext  scheduleCtx) throws Exception;

The corresponding REST method generated using the EJB-REST wizard will be "public net.juniper.jmp.cmp.async.Task runCountriesReport();".

REST Interface Class

The corresponding REST interface class generated by the EJB-REST wizard is:

@RBAC(type = { CRUDEnum.CREATE }, capability = { "HelloWorldCap" })

 "application/vnd.net.juniper.space.job-management.task+json;version=1;q=0.01" })

public Task runCountriesReport();

REST Implementation Class

The corresponding REST implementation class generated by the EJB-REST wizard is:

public Task runCountriesReport() {

 Task task = null;

 try {

   // Create the jobInfoTo instance by calling the EJB method

   net.juniper.jmp.cmp.jobManager.JobInfoTO jobInfoTO = getBean()

   task = new net.juniper.jmp.cmp.async.Task();

   // Set the Task ID from the jobInfoTo instance ID

   JSAuditlogHelper.addModifiedObjectToAuditLog(jobInfoTO, "Creating run-countries-report, Job Id is = " + jobInfoTO.getId());

 } catch (Exception e) {

    JSAuditlogHelper.addDescriptionToAuditLog("Exception  occurred " + e.getMessage());
    throw new WebApplicationException(e);

 } finally {
	 //TODO: Auto generated code

 // Return the Task object created

 return task;


Once the APIs are RESTified and the application is deployed, you can use the REST client to verify its behavior.

For example, you can use the following URL to view the changes:

A complete request URL consists of a schedule service URI and a query parameter with a name queue, which contains the queue location/URL (on which notification is sent upon completion).

Note: For information about creating queues, see Asynchronous API Usage in the API Reference Guide.