GeoEvent Java SDK - Develop custom input (POST)

300
1
01-23-2024 05:31 AM
Nadiia_Matsiuk
New Contributor III

Hello everyone!

My goal is to develop my own input connector for GeoEvent in Java.
Basically, it is enough to completely repeat the input 'Poll an External Website for JSON', but with some improvement of the 'Post Body' option when using the Post method.

As part of my task, I need to make a Post request and each time specify the ID of a new object in the body. For example, I would like the json to be read from the .txt file and the object ID to be included in the body parameter. As a result, a Post request is made for the object id=22, then the process is repeated again and I request data for the object id=23 and so on.

The goal: to make the input dynamic. So that the object id automatically changes in it.

Can anyone please tell me if this is possible? Where to start? Or is it already possible to use some kind of transport in the sample for development?

This needs to be done within 3-4 weeks. But I am a beginner in Java (I have good experience with javaScript, python).

Thanks a lot!

0 Kudos
1 Reply
EricIronside
Esri Regular Contributor

Hey @Nadiia_Matsiuk 

I think this is technically viable, but your timeframe might be tight. If you are new to Java and the GeoEvent SDK this is probably going to be a very steep learning curve for you.  Here's some resoucres I would suggest you read/watch before you get started:

1. Our technical presentation on the GeoEvent SDK from last year's DevSummit: https://mediaspace.esri.com/media/t/1_zvc5a7lq/292702072
2. The GeoEvent SDK documentation located on your GeoEvent Server (for Windows the default location should be here: C:\Program Files\ArcGIS\Server\GeoEvent\sdk\GeoEvent Developer Guide.pdf)

Since you are polling JSON data, you should be able to use the JSON Adapter that comes with GeoEvent. The custom part you will need to build is the Transport.
Once you have the transport and have added it to your GeoEvent Server you can combine it with the OOTB JSON adapter in the GeoEvent Manager > Site > Connectors > Create Connector.

To create the Transport, I would start with the Transport sample provided with the GeoEvent SDK (on Windows the default location should be here: C:\Program Files\ArcGIS\Server\GeoEvent\sdk\samples\).
To create a directory for your Transport to use to get configuration data (like the list of IDs you mention in your post), you will need to add the following to the Blueprint configuration file.

EricIronside_0-1707159563668.png

In order to create the directory and read the file from your Transport, you will need to add the following to your Service class. This will create the data folder for your transport to read/write files. Finally, add the data folder File as an argument to your Transport class' constructor.

EricIronside_1-1707159604411.png

To make periodic HTTP requests, you will want to use the GeoEvent's HTTP Client Service. To gain access to it, you will want to add it to your Blueprint configuration as displayed below.

EricIronside_2-1707159654894.png

Then back in your Transport's service class you will need to add a method to set the HTTP Client Service and then add it to your Transport's constructor.

EricIronside_3-1707159687522.png

Here's a brief example of how to use the GeoEvent HTTP Client inside your Transport class.

EricIronside_4-1707159715930.png

Once you have all that, you can access the file with IDs from your data folder and use the HTTP Client Service to make HTTP requests.