webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

ContextId?

  • 1.  ContextId?

    Posted Thu October 30, 2014 10:17 PM

    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


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: ContextId?

    Posted Fri October 31, 2014 05:40 AM

    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


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 3.  RE: ContextId?

    Posted Mon December 01, 2014 05:44 PM

    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();


    #webMethods
    #webMethods-General
    #Integration-Server-and-ESB