Broker Transactional client - Document retreival issue

Hi…

Our source system which is connected to webMethods BrokerTransactionalClient, sends events which is stored in webMethods Broker queue.
Once all the documents are sent to the broker, a service is invoked which retreives the documents from the Broker queue, through the method Class : class BrokerTransactionalClient and method : getEvents

we use the following code to retreive the events from the Broker queue.
IDataCursor pipelineCursor = pipeline.getCursor();
try
{
BrokerTransactionalClient BTC = (BrokerTransactionalClient) IDataUtil.get(pipelineCursor,“clientConnection”);
int numEvents = BTC.getQueueLength();
String eventContent = new String[numEvents];
BrokerEvent event;
BrokerEvent events = BTC.getEvents(numEvents,-1);
for(int i = 0; i < numEvents; i++)
{
eventContent[i] = events[i].getStringField(“Content”);
BTC.acknowledge(events[i].getReceiptSequenceNumber());
}
IDataUtil.put(pipelineCursor, “eventContents”, eventContent);
IDataUtil.put(pipelineCursor, “numberOfEvents”, numEvents);
Log(“Retrieved " + numEvents + " from the Broker.”,“INFO”,“”);
}
catch(BrokerException E)
{
StackTraceElement stack = E.getStackTrace();
String errorStack = “”;
for(int i = 0; i < stack.length; i++)
{
errorStack = errorStack + stack[i].toString() + “\n”;
}
Log(“Error retreiving events!”, “ERROR”, errorStack);
throw new ServiceException(E);
}
pipelineCursor.destroy();

Now, the interesting part is that, the above code works fine if the document queue size is 15. If the queue size is more, then we get “java.lang.ArrayIndexOutOfBoundsException: 15” error.

Please suggest.

Thanks
Rocky

From the API guide:

So your for loop should use events.length rather than numEvents.

My personal preference would be to make a List object with Arrays.asList(events), then use the Collections framework to loop through the List.

I’m curious as to why you’re using Java services on IS to manage document retrieval from Broker and not the normal IS-Broker interaction facilities.