I'm not sure what this is not working (given that it worked previously). I'll take a look.
The task is binary data. My first guess is this:- String queuedTask = taskInfo.getBody(); String is UTF-16 encoded while the body is a bunch of bytes. The process of decoding and re-encoding has a potential of corrupting the data. I suggest using *getBodyAsBytes<http://code.google.com/appengine/docs/java/tools/localunittesting/javadoc/com/google/appengine/api/taskqueue/dev/QueueStateInfo.TaskStateInfo.html#getBodyAsBytes()> instead.* On Tue, Apr 26, 2011 at 11:00 PM, Brendan Doherty < [email protected]> wrote: > I've also tried the code below, however I get the following error on the > line client.sendRequest(request); > > Perhaps I'm not encoding the task body correctly? > > com.google.apphosting.utils.servlet.DeferredTaskServlet: Deferred task > failed exception: > com.google.apphosting.utils.servlet.DeferredTaskServlet$DeferredTaskException: > java.io.StreamCorruptedException: invalid stream header: EFBFBDEF > > String queueName = QueueFactory.getDefaultQueue().getQueueName(); > > ServletRunner sr = new ServletRunner(); > sr.registerServlet( > "/_ah/queue/__deferred__", > > > com.google.apphosting.utils.servlet.DeferredTaskServlet.class.getCanonicalName()); > > > LocalTaskQueue localTaskQueue = > LocalTaskQueueTestConfig.getLocalTaskQueue(); > > ServletUnitClient client = sr.newClient(); > > while (!getQueue().getTaskInfo().isEmpty()) { > > TaskStateInfo taskInfo = getQueue().getTaskInfo().iterator().next(); > > String queuedTask = taskInfo.getBody(); > > String taskName = taskInfo.getTaskName(); > > WebRequest request = new > PostMethodWebRequest("http:/_ah/queue/__deferred__", > new ByteArrayInputStream(queuedTask.getBytes()), > "application/x-binary-app-engine-java-runnable-task"); > > request.setHeaderField("X-AppEngine-QueueName", queueName); > > try { > client.sendRequest(request); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (SAXException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > // localTaskQueue.runTask(queueName, taskName); > > localTaskQueue.deleteTask(queueName, taskName); > } > localTaskQueue.flushQueue(queueName); > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- Gianni Mariani Google, Sydney -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
