views:

224

answers:

1

I would like to know at runtime in which of several possible host processes my current code is executing. The host processes have configured names at the Biztalk management level, but I need to know which process I'm in from inside the code.

I didn't find any supported way to do this and I'm even stuck with the search for an unsupported method :-)

Edit: Thanks to tomasr for the answer. I would need that mainly for logging/tracing purposes. Not only to display the host the ode is running in but also to determine the appropriate trace level.

That also means, I need this deep down on library level and it has to be fast. I can't go and get the call stack for example to find out which top-level-component (orchestration, pipeline, whatever) the code is running in.

On the other hand I could figure it out just once in a singleton constructor. That would be called once per AppDomain and thus could take a little while to look things up. But I probably don't have a very meaningful call stack there, so we are back on square one :-/

Edit2: The Biztalk Management DB must contain the information I need. It knows which hosts are started on which server and (probably) the process id's of these host processes. If someone has a pointer where I could start looking there, that would help me, too.

+1  A: 

As far as I know, there isn't any "simple" way of doing it. One (somewhat backwards) way of getting that info would be to use the ExplorerOM API to query the management configuration data and figure out where you're executing and what host/handler you're running in.

For example, if you're doing this from a PipelineComponent, you could look for the port name in the message context and then look it up using ExplorerOM. Then, use that to query the Handler associated with the adapter and from there get the host name. Would be something similar for the orchestration, though you'd look for the full orchestration name.

Out of curiosity, why do you need this information?

tomasr