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

trigger problem

  • 1.  trigger problem

    Posted Tue October 16, 2007 04:25 PM

    Hi all,
    in my trigger (on insert, update and delete events) I perform an update (via xquery) of existing documents in the same collection and of the same doctype of the current document. But an error message was returned:

    Database access failure (7126, INOSXE7126, Server extension failed, INOSXE7023: Function ‘Ead.InsertDoc’ failed, because XML callback failed with error ‘8504’)

    where:

    INOXME8504 XML maximum request duration exceeded

    but it is really a maximum request duration exceeded problem? I suppose it’s a lock problem.

    Every help and suggestion is appreciated.
    Thanks in advance,

    Pam

    PS: the xquery performing code is

    public String TaminoXQuery(String expression)
    throws TServerNotAvailableException
    {
    String resultXML = “”;
    try
    {
    TResponse response = null;
    conn = getConnection(); // conn is my TConnection
    TLocalTransaction transaction = conn.useLocalTransactionMode();
    // collection is my collection
    TXMLObjectAccessor xmlObjectAccessor = conn.newXMLObjectAccessor(TAccessLocation.newInstance(collection), TDOMObjectModel.getInstance());
    TXQuery xquery = TXQuery.newInstance(expression);
    try
    {
    response = xmlObjectAccessor.xquery(xquery);
    }
    catch(TAccessorException accessorException)
    {
    transaction.rollback();
    conn.useAutoCommitMode();
    conn.close();
    throw accessorException;
    }
    StringWriter stringWriter = new StringWriter();
    while(response.getXMLObjectIterator().hasNext())
    try
    {
    response.getXMLObjectIterator().next().writeTo(stringWriter);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    try
    {
    resultXML = new String(stringWriter.toString().getBytes(“UTF-8”));
    }
    catch(UnsupportedEncodingException e1)
    {
    e1.printStackTrace();
    }
    transaction.commit();
    conn.useAutoCommitMode();
    conn.close();
    return resultXML;
    }
    catch(Exception e)
    {
    return resultXML;
    }
    }


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: trigger problem

    Posted Fri October 19, 2007 03:14 PM

    Turn on XML request logging and see which request fails with the 8504. It is possible that it is a transaction timeout.


    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: trigger problem

    Posted Tue October 23, 2007 11:06 AM

    Hi Mark,
    you are right: according to the XML request logging it is a transaction timeout. But why?
    For example, the insert event get the tamino id of the current document and only perform an xquery like this:

    declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
    update for $a in input()/ead where tf:getInoId($a)=2
    do insert Arch.Barb.Colonna.di.Sciarra.serie1.sottoserie1 into $a

    If I perform it with Tamino Interactive Interface, the update is executed.
    I am not a Tamino expert, could you help me to understand?
    Thanks in advance!

    Pam


    #Tamino
    #webMethods
    #API-Management


  • 4.  RE: trigger problem

    Posted Wed October 24, 2007 10:03 AM

    Is it possible that the query is run on the same collection/doctype as the trigger? I.e. it may be a locking conflict within the trigger?


    #Tamino
    #API-Management
    #webMethods


  • 5.  RE: trigger problem

    Posted Mon October 29, 2007 09:15 AM

    Hi Mark,
    the xquery runs on the same collection/doctype as the trigger, as I wrote (no clearly!) in my first email.
    It may be a locking conflict within the trigger! What can I do to resolve it?
    Thanks in advance for your precious help,

    Pam


    #API-Management
    #Tamino
    #webMethods


  • 6.  RE: trigger problem

    Posted Mon October 29, 2007 10:24 AM

    Hi Pam,

    From your code I see that you try to query using the Tamino Java API. This opens a new session in parallel to the existing session in which the trigger function is called. So this explains the locking.

    You should rather use X-Tension callbacks (see Tamino documentation on X-Tension: Tamino Server Extensions → Developing Tamino Server Extensions → Callbacks). The function to use is

    int SxsXMLXQuery (String collection, String query, Result result);

    This XQuery is called inside the same session and will thus (hopefully) not produce any locking problems.

    Best regards,
    Julius


    #webMethods
    #Tamino
    #API-Management


  • 7.  RE: trigger problem

    Posted Mon October 29, 2007 01:27 PM

    Hi Julius,
    thank you very much, I believe it is just what I need!
    Please, can you give me some java example?

    Pam


    #webMethods
    #API-Management
    #Tamino


  • 8.  RE: trigger problem

    Posted Mon October 29, 2007 03:15 PM

    Hi Pam,

    I found a sample function that uses XQuery to write in another collection. It is a map-in function, but a trigger function acts similar:

    
    public void mapin (int object_id, int element_id, String document, StringBuffer nodeinfo)
    {
    Result result = new Result();
    int rc = 0;
    
    // xquery update to collection MAPTEST:
    StringBuffer Response = new StringBuffer();
    String XQuery = "update insert <item><KEY>" + object_id + element_id +
    "</KEY>" + document + "</item> into input()/TEST_ROOT";
    rc = SxsXMLXQuery ( "MAPTEST", XQuery, result);
    if (rc != 0) {
    StringBuffer errMsg = new StringBuffer();
    SxsXMLGetMessage (errMsg);
    SxsException(rc, errMsg.toString());
    }
    }

    I hope this is of help for you.

    Best regards,
    Julius


    #webMethods
    #Tamino
    #API-Management


  • 9.  RE: trigger problem

    Posted Tue October 30, 2007 11:34 AM

    Hi Julius,
    thanks very much for your precious help and your availability.
    Please, help me again!

    I work with Tamino 4.4.1.1 and I still solve one/two problems:

    1. for my java trigger class Ead (extends ASXJBase), the method SxsXMLXQuery(String, String, Result) is undefined;

    2. perhaps the problem lies in how I defined class Result, its code is very simple:

                             public class Result {
      public Result(){}
      }
      

    and it is located in an appropriate jar (in “Developing Tamino Server Extensions”, I have not been able to find additional information)

    Any suggestion will be appreciated!!! Thanks a lot!

    Pam


    #Tamino
    #API-Management
    #webMethods


  • 10.  RE: trigger problem

    Posted Tue October 30, 2007 11:58 AM

    Hi Julius,
    excuse me for my great error! I have found Result class in com.softwareag.ino.sxs package!

    Pam


    #API-Management
    #Tamino
    #webMethods


  • 11.  RE: trigger problem

    Posted Tue October 30, 2007 11:59 AM

    The Result class is described in the document you mentioned.


    #Tamino
    #API-Management
    #webMethods


  • 12.  RE: trigger problem

    Posted Tue October 30, 2007 12:20 PM

    Hi Julius,
    my triggers works very fine now!
    Thanks very very very much!!! :lol:

    Pam


    #API-Management
    #Tamino
    #webMethods