I cant able to query the queue element using queuequery in PE filenet

958 views Asked by At

I am facing an issue when i try to query the queue using createquery api to fetch the queue element.

I am getting an error at the while statement stating the error below as

errorjava.lang.illegalstateexception :unread block data

i dont know why i am getting this error. I can able to use the fetchcount() api to get the count of workitem in the queue but the hasnext() api is not working nor next().

Is there any reason why this statement is not getting executed. is this related to any java issue. Can any one help

The code is

VWSession session = new VWSession(); 
session.setBootstrapCEURI(Ceuri); 
session.logon(cename, fnPassword, connectionPoint); 
VWQueue queue = session.getQueue(queue)); 
int queryFlag = VWQueue.QUERY_NO_OPTIONS; 
int fetchType = VWFetchType.FETCH_TYPE_STEP_ELEMENT; 
VWQueueQuery queueQuery = queue.createQuery(null,null, null,queryFlag, null, null, fetchType); 
while (queueQuery.hasNext()) { 
   queueElement = (VWStepElement) queueQuery.next(); 
} 
1

There are 1 answers

0
Ajay Kumar On

In you main (calling) method, do this :

    VWSession vwsession = new VWSession();
    vwsession.setBootstrapCEURI("http://servername:9080/wsi/FNCEWS40MTOM/");
    vwsession.logon("userid", "password", "ConnPTName");
    IteratePEWorkItems queueTest = new IteratePEWorkItems();
    queueTest.testQueueElements(vwsession);

Later on create below metioned helper method:

public void testQueueElements(VWSession vwsession) {
    System.out.println("Inside getListOfWorkitems: : ");
    VWRoster roster = vwsession.getRoster("DefaultRoster");
    int fetchType = VWFetchType.FETCH_TYPE_STEP_ELEMENT;
    int queryFlags = VWQueue.QUERY_READ_UNWRITABLE;
    try {
        dispatchWorkItems(roster, fetchType, queryFlags, vwsession);
    } catch (Exception exception) {
        log.error(exception.getMessage());
    }
}

public void dispatchWorkItems(VWRoster roster, int fetchType, int queryFlags, VWSession vwsession) {
    String filter = "SLA_Date>=:A";
    // get value and replace with 1234567890 as shown in process administrator
    Object[] subVars = { 1234567890 };
    VWRosterQuery rosterQuery = roster.createQuery(null, null, null,
    VWRoster.QUERY_MIN_VALUES_INCLUSIVE | VWRoster.QUERY_MAX_VALUES_INCLUSIVE, filter, subVars,
    VWFetchType.FETCH_TYPE_WORKOBJECT);
    int i = 0;
    // Iterate work items here...
    while (rosterQuery.hasNext() == true) {
        VWWorkObject workObject = (VWWorkObject) rosterQuery.next();
        try {
            i++;
            System.out.println(" Subject: " + workObject.getFieldValue("F_Subject") + " Count: " + i);
        } catch (Exception exception) {
            exception.printStackTrace();
            log.error(exception);
        }
    }
}

Try it and share the output.