ContextId?

Hi,

I would like to improve the monitoring of my integration. To do this, I need to get the contextID used in monitoring tables, from the IS service. I don’t find which methods I must use to get It. The Idea is to use the ContextID as a key to join my specific logging table with the webMethods one.

Do you have some idea to do this?

Thanks a lot for your help

Hi,
To get the contextID you can explore the services under pub.monitor.service.*.May be you cane use pub.monitor.service:getList.

Or in other way you can set your services with custom ContextID which may be specific to your service(like transaction ID)and can link this ID with your logging table.
For this you can use pub.flow:setCustomContextID.

Thanks

1 Like

Hi,

You can use following code to get the context id of a service:

                            String[] contextStack;
                            String currentContextID = "";
                            String currentParentID = "";
                            String currentRootID = "";
			
			Stack stack=new Stack();

IDataCursor pipelineCursor_1 = pipeline.getCursor();
try{
contextStack = InvokeState.getCurrentState().getAuditRuntime().getContextStack();

                                            if(contextStack!=null)
                                                            if(contextStack.length >=3){
                                                                            currentRootID = contextStack[0];
                                                                            currentParentID = contextStack[1];
                                                                            currentContextID = contextStack[2];
                                                            }else if (contextStack.length>=2){
                                                                                            currentRootID = contextStack[0];
                                                                                            currentParentID = contextStack[1];
                                                                                            currentContextID = currentParentID;
                                                            }else if (contextStack.length>=1){
                                                                                            currentRootID = contextStack[0];
                                                                                            currentParentID = currentRootID;
                                                                                            currentContextID = currentRootID;
                                                             }

IDataUtil.put(pipelineCursor_1, “contextStack”, contextStack);
}catch(Exception ex){
//ServiceException sx = new ServiceException(ex);

                            }
                            // pipeline

                            IDataUtil.put(pipelineCursor_1, "currentContextID", currentContextID); // Assuming that caller is looking for its context ID. currentContextID extracted is the context ID for the java service, not the caller service.
	IDataUtil.put(pipelineCursor_1, "currentParentID", currentParentID);   

IDataUtil.put(pipelineCursor_1, “currentRootID”, currentRootID);

pipelineCursor_1.destroy();