IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

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
  • 1.  How does webMethods generate the ContextId

    Posted Mon July 21, 2014 04:25 AM

    Dear Experts
    I am designing an Error Handling solution. I need to know how the ContextId is generated in webMethods.
    Can someone please help ?


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


  • 2.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 06:54 AM

    Do you want the flow/java service to generate the contextId or something else?


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


  • 3.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 08:00 AM

    Yes, correct Mahesh. I am looking for the flow/java service that webMethods uses to generate it. Also, if you could say how that service is called when an error occurs, would be good.


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


  • 4.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 08:23 AM

    You must be able to find the java service in WmPublic package to get/set the contextId from webMthods 8.2 and up.

    Can you share your version? We can write a java code using the wM API.

    public static final void getContextIDs(IData pipeline) throws ServiceException {
    
    String[] contextStack;
    String currentContextID = "";
    String currentParentID = "";
    String currentRootID = "";
    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;
    }
    }catch(Exception ex){
    ServiceException sx = new ServiceException(ex);
    throw sx;
    }
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put(pipelineCursor_1, "currentContextID", currentParentID); // Assuming that caller is looking for its context ID. currentContextID extracted is the context ID for the java service, not the caller service.
    pipelineCursor_1.destroy();
    }

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


  • 5.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 08:31 AM

    Hi Mahesh, We are using wM 9.5 in this project.


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


  • 6.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 08:51 AM

    Hi Mahesh
    Thanks for the code for getting the ContextId.

    I am actually looking for the services(flow/java) that webMethods uses to generate the ContextId and how those are invoked when an error/exception occurs.


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


  • 7.  RE: How does webMethods generate the ContextId

    Posted Mon July 21, 2014 08:56 AM

    I am not sure! May be others might be able to help you on your question. Keep us posted if you find something.


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


  • 8.  RE: How does webMethods generate the ContextId

    Posted Fri September 26, 2014 08:08 PM

    The generation of contextID is internal and is present in jar files provided by webMethods. The way it works is like this:

    When a service runs it generates a context id. If its a top level service, the root, parent and context id will be same, if its a 1st level child service then the context id will be different , but root and parent context id will be same. If its embedded at level 2 or 3 then all 3 will be different. The SAG code generates a context id whenever it spawns a thread or does an invoke of one process from another.

    If you want to get the context id, you can do so using the code Mahesh gave earlier. You can get the context id either if you use the Exception Event manager and set the exception event handling to be synchronous or you can call the exception handling service below getLastError


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