Solved

Specify Queue when running job from API?

  • 5 March 2021
  • 7 replies
  • 11 views

Badge +1

I have a workbench on FME server I need to start running by calling URL through an external script. (In my case a poweshell script.) I can create all the parameters necessary to run workbench, but I need to specify which Queue or FME Server this workbench will be run on.

 

I have created a Job Queue with the FME Server I want to run on. When running this in browser I can use the Advanced option and select the Job Queue. This will then run where I need it to run. But I can't see a how to get this to happen when submitting through API/external script.

icon

Best answer by hollyatsafe 6 March 2021, 01:15

View original

7 replies

Userlevel 6
Badge +31

What version FME server? This changed in 2018.

Badge +1

FME Server 2020.2

Build 20787 - win64

Badge +1

I've currently coded my script to use the FME JobSubmitter Service to call the workbench but I'm willing to switch this to run through Rest API instead. What ever will let me specify the Job Queue for Workbench.

https://docs.safe.com/fme/html/FME_Server_Documentation/ReferenceManual/job_submitter_service.htm

Userlevel 4
Badge +25

Are you using transformations/submit/[repository]/[workspace]?

I can see how you submit it as a request body, using a TM directive, specifying TMDirective:

  "TMDirectives": {
    "tag": "queuename"
  },

...but I'm not sure if you can put that into a URL. 

The other way of doing it would be to assign the repository to a particular queue. That way any job that is run from that repository will use its own default queue.

Does that help in any way?

Userlevel 4
Badge +25

Are you using transformations/submit/[repository]/[workspace]?

I can see how you submit it as a request body, using a TM directive, specifying TMDirective:

  "TMDirectives": {
    "tag": "queuename"
  },

...but I'm not sure if you can put that into a URL. 

The other way of doing it would be to assign the repository to a particular queue. That way any job that is run from that repository will use its own default queue.

Does that help in any way?

You could assign the repository to a queue using a plain URL though, so if a two-step process works:

1: Assign the repository to the required queue

2: Submit the job from that repository

[Optional: 3: Reassign the repository back to its original queue]

Badge +1

Assigning and reassigning isn't going to work because I might have jobs calling the URL for running this job within seconds of each, each for different queue name. We have specific FME servers tasked with different queue names. Each will be running the identical workspace, but with different parameters. However I need to start these workspace(s) from an external script that will tell it which FME server needs to run.

I will try using the transformations/submit/[repository]/[workspace]. That will let me get what I need for queuename and I can still use a FME token to call this remotely through an external script.

Badge +2

Hi @ssmith_ftr​ ,

 

In order to assign a queue to a job that is being run either via a Webhook (e.g. a URL for one of the transformation services such as fmejobsubmitter) or via the REST API (e.g. using the transformations endpoint), you can make use of Job Directives to assign values to those parameters you'd usually find under the 'Advanced' section on the Run Workspace page.

 

In particular, you'll need to use the tm_tag directive to assign a queue. 

 

In older versions of FME (prior to 2018) we referred to 'queues' as 'tags' and since this was an exposed endpoint in our REST API the name of this directive had to remain the same for backwards compatibility.

 

To make use of Job Directives in a Webhook you can specify them in the query string e.g. 

 

https://<hostname>/fmejobsubmitter/Samples/austinApartments.fmw?tm_tag=<QUEUENAME>

 

Alternatively, as Mark mentioned if you were running the job via a REST API request you'd need to specify this as part of the upload body as JSON e.g. 

 

"TMDirectives": { "tag": "<QUEUENAME>" }

 

For the REST API route, you can check out the documentation for a full example of what the upload body would look like for one of our Sample workspaces.

 

As well as queue assignment, job directives include parameters for the Queued Job Expiry Time, Running Job Expiry Time and Run Until Cancelled advanced settings.

Reply