trigger problem

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;
}
}

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

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

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?

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

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

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

Pam

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

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

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

Pam

The Result class is described in the document you mentioned.

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

Pam