Can a Service can access its own Name at runtime

Can I find out he name of the service that is currently running inside of the service?

Ie, for logging I might want to write a message like this:

%serviceName% - %datetime% - %error%

WITHOUT hard coding the service name, obviously.

Lucas.

I do not know if there is a built-in service to do so, but if you are writing a java service, you can get the name of the calling service by making an API call -> Service.getCallingService().

Correct me if I am wrong, but I think that in your main flow, when you grab the exception, you also want to get the name of the service that caused the exception. In order to handle this, I would create a util java service e.g. getCallingServiceName, that gets the name of the calling service and places it in the pipeline. Thereafter, in each flow, I would call this java service as the first step to populate the variable, say serviceName… so if this flow later causes an exception, the service name would already be in the pipeline and can be retrieved in the getLastError using %lastError/pipeline/serviceName%

HTH, Roh

Hi,

If you want to get the service name for error handling purpose then you can implement TRY-Catch blocks and in the Catch block you can invoke the Java service-> <psutilities.misc:getservicename> in the PSUtilities package. It gives you:

  • folderName
  • serviceName
  • fullName
    and the error message.

Sachin

Humm… that won’t work for what I want to do…but thanks for the posts!

What I really need is to be able to get the name of a the service that called the current serivce. Is that possible?

serviceA invokes serviceB and within serviceB I want to be able to get access to the name of serviceA with out passig it in.

Sorry, I asked the question wrong.

Luke.

I know this could be done if serviceB is a java service.

Roh