Create a custom async WPS process

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Create a custom async WPS process

GeoServer - User mailing list
Hi,
I want to implement a custom WPS process that can be called asynchronously.
Following this guide:
I was able to implement the process, but I'm not able to add the progress-advancing to it. I mean if I call my process in asynchronous way using:
<wps:ResponseDocument storeExecuteResponse="true" status="true">
then I call GetExecutionStatus to get its progress, the percentCompleted is always 0, until the process finishes.
How can I make the progress (percentCompleted) advances?

Thanks,
Nanaso



_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a custom async WPS process

Spirifer
Hi,

To have a progress for your process, you need to add a ProgressListener
parameter in the execute method.

An example:
        @DescribeResult(name = "result", description = "output result")
        public String execute(@DescribeParameter(name = "name", description
= "name to return") String name,
                        ProgressListener listen) throws InterruptedException
{

                listen.progress(10f);
                Thread.sleep(10 * 1000);
                listen.progress(30f);

                Thread.sleep(10 * 1000);
                listen.progress(60f);

                Thread.sleep(10 * 1000);
                listen.progress(100f);

                return "Hello, " + name;
        }

Cheers



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html


_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a custom async WPS process

GeoServer - User mailing list
Hi Spirifer,
Thanks a lot for your reply.
I was waiting for such answer for a long time.

Regards,
Nanaso


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, December 1, 2018 8:04 PM, Spirifer <[hidden email]> wrote:

> Hi,
>
> To have a progress for your process, you need to add a ProgressListener
> parameter in the execute method.
>
> An example:
> @DescribeResult(name = "result", description = "output result")
> public String execute(@DescribeParameter(name = "name", description
> = "name to return") String name,
> ProgressListener listen) throws InterruptedException
> {
>
> listen.progress(10f);
> Thread.sleep(10 * 1000);
> listen.progress(30f);
>
> Thread.sleep(10 * 1000);
> listen.progress(60f);
>
> Thread.sleep(10 * 1000);
> listen.progress(100f);
>
> return "Hello, " + name;
> }
>
> Cheers
>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html
>
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to this list:
>
> -   Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
> -   The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html
>
>     If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>     [hidden email]
>     https://lists.sourceforge.net/lists/listinfo/geoserver-users
>




_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a custom async WPS process

GeoServer - User mailing list
In reply to this post by Spirifer
Hi Spirifer,
I've tried the method you mentioned like the following:

@DescribeProcess(title = "Test", description = ".")
public class Test implements GeoServerProcess {

@DescribeResult(name = "result", description = "output result")
public String execute(@DescribeParameter(name = "name", description = "name to return") String name,
        ProgressListener listen) throws InterruptedException {
                listen.progress(10f);
                Thread.sleep(10 * 1000);
                listen.progress(30f);
                Thread.sleep(10 * 1000);
                listen.progress(60f);
                Thread.sleep(10 * 1000);
                listen.progress(100f);
                return "Hello, " + name;
        }
}


And when I try to test it using following Post request:

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>gs:Test</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>name</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>koko</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:ResponseDocument storeExecuteResponse="true" status="true">
    <wps:Output mimeType="application/json">
      <ows:Identifier>result</ows:Identifier>
    </wps:Output>
    </wps:ResponseDocument>
  </wps:ResponseForm>
</wps:Execute>


It gives the following response:

<?xml version="1.0" encoding="UTF-8"?>
<wps:ExecuteResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" service="WPS" serviceInstance="http://localhost:6256/geoserver/ows?" statusLocation="http://localhost:6256/geoserver/ows?service=WPS&amp;version=1.0.0&amp;request=GetExecutionStatus&amp;executionId=58745f88-16a0-4d4b-ad10-9a5e0f23f172" version="1.0.0">
    <wps:Process wps:processVersion="1.0.0">
        <ows:Identifier>
            gs:Test
        </ows:Identifier>
        <ows:Title>
            Test
        </ows:Title>
        <ows:Abstract>
            .
        </ows:Abstract>
    </wps:Process>
    <wps:Status creationTime="2018-12-20T12:57:57.257Z">
        <wps:ProcessAccepted>
            Process accepted.
        </wps:ProcessAccepted>
    </wps:Status>
</wps:ExecuteResponse>


And when I call the following GET request (to monitor the process progress):

http://localhost:8080/geoserver/ows?service=WPS&version=1.0.0&request=GetExecutionStatus&executionId=58745f88-16a0-4d4b-ad10-9a5e0f23f172

It gives the following response:

<wps:ExecuteResponse xml:lang="en" service="WPS" serviceInstance="http://localhost:6256/geoserver/ows?" statusLocation="http://localhost:6256/geoserver/ows?service=WPS&version=1.0.0&request=GetExecutionStatus&executionId=58745f88-16a0-4d4b-ad10-9a5e0f23f172" version="1.0.0"><wps:Process wps:processVersion="1.0.0"><ows:Identifier>gs:Test</ows:Identifier><ows:Title>Test</ows:Title><ows:Abstract>.</ows:Abstract></wps:Process><wps:Status creationTime="2018-12-20T12:57:57.257Z"><wps:ProcessFailed><ows:ExceptionReport version="1.1.0"><ows:Exception exceptionCode="NoApplicableCode"><ows:ExceptionText>Process failed during execution
Parameter arg1 is missing but has min multiplicity &gt; 0</ows:ExceptionText></ows:Exception></ows:ExceptionReport></wps:ProcessFailed></wps:Status></wps:ExecuteResponse>


It tells that there is a missing parameter!!
What is my problem? how should I call this WPS?

Thanks,
Nanaso


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, December 1, 2018 8:04 PM, Spirifer <[hidden email]> wrote:

> Hi,
>
> To have a progress for your process, you need to add a ProgressListener
> parameter in the execute method.
>
> An example:
> @DescribeResult(name = "result", description = "output result")
> public String execute(@DescribeParameter(name = "name", description
> = "name to return") String name,
> ProgressListener listen) throws InterruptedException
> {
>
> listen.progress(10f);
> Thread.sleep(10 * 1000);
> listen.progress(30f);
>
> Thread.sleep(10 * 1000);
> listen.progress(60f);
>
> Thread.sleep(10 * 1000);
> listen.progress(100f);
>
> return "Hello, " + name;
> }
>
> Cheers
>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html
>
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to this list:
>
> -   Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
> -   The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html
>
>     If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>     [hidden email]
>     https://lists.sourceforge.net/lists/listinfo/geoserver-users
>




_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a custom async WPS process

Spirifer
Hi,

You are using the wrong import for the ProgressListener:
import org.geotools.util.ProgressListener;

will give this error :
ERROR [wps.executor] - Process execution failed
org.geotools.process.ProcessException: Parameter arg1 is missing but has min
multiplicity > 0
        at
org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.buildProcessArguments(AnnotationDrivenProcessFactory.java:728)
        at
org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.execute(AnnotationDrivenProcessFactory.java:588)
        at
org.geoserver.wps.executor.ProcessStartupFilter$ProcessStartupWrapper.execute(ProcessStartupFilter.java:51)
        at
org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:201)
        at
org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:169)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

You must use this import:
import org.opengis.util.ProgressListener;




--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html


_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a custom async WPS process

GeoServer - User mailing list
Hi Spirifer,
Thanks a gain for your reply.

I fixed it as you told.
Now When I call a GET request to:

http://localhost:6256/geoserver/ows?service=WPS&version=1.0.0&request=GetExecutionStatus&executionId=370b5742-7f02-43b5-acf6-4a81df4836a3

It gives:

<ows:ExceptionReport version="1.1.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://localhost:6256/geoserver/schemas/ows/1.1.0/owsAll.xsd"><ows:Exception exceptionCode="NoApplicableCode"><ows:ExceptionText>Unknown process gs:Test</ows:ExceptionText></ows:Exception></ows:ExceptionReport>

This is what I receive during process execution, but after the process finishes, I got the following response:

<wps:ExecuteResponse xml:lang="en" service="WPS" serviceInstance="http://localhost:6256/geoserver/ows?" statusLocation="http://localhost:6256/geoserver/ows?service=WPS&version=1.0.0&request=GetExecutionStatus&executionId=370b5742-7f02-43b5-acf6-4a81df4836a3" version="1.0.0"><wps:Process wps:processVersion="1.0.0"><ows:Identifier>gs:Test</ows:Identifier><ows:Title>Test</ows:Title><ows:Abstract>.</ows:Abstract></wps:Process><wps:Status creationTime="2018-12-21T14:20:29.425Z"><wps:ProcessSucceeded>Process succeeded.</wps:ProcessSucceeded></wps:Status><wps:ProcessOutputs><wps:Output><ows:Identifier>result</ows:Identifier><ows:Title>output result</ows:Title><wps:Data><wps:LiteralData>Hello, koko</wps:LiteralData></wps:Data></wps:Output></wps:ProcessOutputs></wps:ExecuteResponse>

What is the problem?

Thanks,
Nanaso



Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, December 20, 2018 10:55 PM, Spirifer <[hidden email]> wrote:

> Hi,
>
> You are using the wrong import for the ProgressListener:
> import org.geotools.util.ProgressListener;
>
> will give this error :
> ERROR [wps.executor] - Process execution failed
> org.geotools.process.ProcessException: Parameter arg1 is missing but has min
> multiplicity > 0
>
>     at
>
>
> org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.buildProcessArguments(AnnotationDrivenProcessFactory.java:728)
> at
> org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.execute(AnnotationDrivenProcessFactory.java:588)
> at
> org.geoserver.wps.executor.ProcessStartupFilter$ProcessStartupWrapper.execute(ProcessStartupFilter.java:51)
> at
> org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:201)
> at
> org.geoserver.wps.executor.DefaultProcessManager$ProcessCallable.call(DefaultProcessManager.java:169)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
>
> You must use this import:
> import org.opengis.util.ProgressListener;
>
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html
>
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to this list:
>
> -   Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
> -   The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html
>
>     If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>     [hidden email]
>     https://lists.sourceforge.net/lists/listinfo/geoserver-users
>




_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users