Select to view content in your preferred language

SOI & RequestID

832
5
05-27-2024 02:55 PM
Labels (1)
Trevor_Hart
Frequent Contributor

Hello

At ArcGIS Server 10.7 the "Request ID", aka requestId, was added to the service logs.

Is it possible to get the requestId in a SOE/SOI? I dont see any refererences to requestId in the SDK (Java) documentation.

The request properties contains ETag but this isnt the requestId.

Thanks

0 Kudos
5 Replies
Trevor_Hart
Frequent Contributor

200w.gif

Bueller…?

0 Kudos
Trevor_Hart
Frequent Contributor

Anyone…?

0 Kudos
Trevor_Hart
Frequent Contributor

giphy

0 Kudos
LorenCress
Esri Contributor

@Trevor_Hart

I have an answer for you!

import java.io.IOException;
import com.esri.arcgis.system.EnvironmentManager;
import com.esri.arcgis.system.IServerEnvironment;
import com.esri.arcgis.system.IServerEnvironmentProxy;
import com.esri.arcgis.system.UID;

class whatever
{
	public static UUID getRequestID() throws AutomationException, IOException
    {
        EnvironmentManager envMgr = new EnvironmentManager();
        try
        {
            UID envUID = new UID();
            envUID.setValue("{32d4c328-e473-4615-922c-63c108f55e60}");
            Object envObj = envMgr.getEnvironment(envUID);
            IServerEnvironment env = new IServerEnvironmentProxy(envObj);
            
            var reqIdStr = env.getProperties().getProperty("RequestID");
            
            if (reqIdStr != null)
            {
                UUID reqId;
                try
                {
                    reqId = UUID.fromString(reqIdStr.toString());
                    return reqId;
                }
                catch(IllegalArgumentException e)
                {
                    
                }
                return UUID.randomUUID();
            }
            else
            {
                return UUID.randomUUID();
            }
        }
        finally {
            envMgr.release();
        }
    }
}

 

Trevor_Hart
Frequent Contributor

OMG @LorenCress thank you so much, I will test this out ASAP 😄

0 Kudos