• SANTOSH VATPALLY 8
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I have a java cron job which run twice a day and sometime I get the error message show on the subject.

 

It is strange because it could be running for days w/o this error and at some point out of the blue it would choke.

 

Below is my java code where I make the call to the force.com API and process the result from the queryResult object.

 

Any help will be appreciated, Thank you.

 

private static void getOpportunityInfo(){
		
		try{
			
			boolean done = false;
			QueryResult qr = connection.query(BASE_QUERY + " WHERE RecordTypeId = '" + MY_RECORD_TYPE_ID + "' AND (Opportunity__r.CloseDate >= 2010-01-01)");
			
			if (qr.getRecords() != null && qr.getRecords().length > 0){ 
				
				log.debug("QueryResults.getRecords().length: " + qr.getRecords().length);
				
				lineItems = new ArrayList<Opportunity_Line_Item__c>();
				
				while (!done){
					
					log.debug("	Processing next batch of opportunities...");
					
					for (SObject sObj : qr.getRecords()) {
						
						try {
							
							Opportunity_Line_Item__c ol = (Opportunity_Line_Item__c)sObj;
							lineItems.add(ol);
							
						}catch(ClassCastException ex){
							log.error("Exception while processing opportunity line items!, continue with next itteration...", ex);
							continue;
						}
					}
					
					if (qr.isDone()) {
						done = true;
					} else {
						qr = connection.queryMore(qr.getQueryLocator());
					}
				}
				log.debug("Opportunity Line Items size: " + lineItems.size());
			}
		}catch(Exception e){
			log.error("Exception: ", e);
		}
	}

 

  • December 19, 2011
  • Like
  • 0