cerestorm
cerestorm

Reputation: 53

Batch Process - Could not deserialize object

I've been playing around with the Batch processor recently, and in testing it's been working fine.

I have since added it to our main project flow and I'm getting a strange issue.

The Batch process itself contains nothing but a Logger, and the payload sent to it is a LineIterator.

The problem I'm having is it's throwing a SerializationException. The odd thing is the first time it's run it throws that exception at run time. After that it won't compile, throwing the same exception.

Here's the batch process from the flow and the pertinent stack info when failing to build.The full trace is attached to this post on the Mule forum: https://forums.mulesoft.com/questions/65671/batch-process-could-not-deserialize-object.html

 <batch:job name="revenue-batch-Flow" block-size="10">
 <batch:process-records>
     <batch:step name="Batch_Step" accept-expression="#[!org.apache.commons.lang.StringUtils.isBlank( payload )]">
         <logger message="#[payload]" level="INFO" doc:name="Logger"/>
     </batch:step>
 </batch:process-records>
</batch:job>

 Caused by: com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException
 Serialization trace:
 value (org.mule.transformer.types.TypedValue)
 properties (org.mule.session.DefaultMuleSession)
 session (org.mule.DefaultMuleEvent)
 muleEvent (com.mulesoft.module.batch.DefaultBatchJobInstance)

Any ideas on what's causing this strange behaviour?

UPDATE

Just to add a bit of context. I'm attempting to iterate over the lines in a file that has been read from SFTP.

This endpoint itself is created mid-flow in a Java component:

    @Override
public Object onCall(MuleEventContext muleEventContext) throws Exception {

    String sftpUri = muleEventContext.getMessage().getProperty( "sesSftpUri", PropertyScope.SESSION);

    EndpointBuilder endpointBuilder = muleEventContext.getMuleContext().getEndpointFactory().getEndpointBuilder( sftpUri );
    endpointBuilder.addMessageProcessor(new MessageFilter(new FilenameWildcardFilter(muleEventContext.getMessage().getProperty( "sesFileName", PropertyScope.SESSION)) ));

    InboundEndpoint inboundEndpoint = endpointBuilder.buildInboundEndpoint();

    MuleMessage muleMessage = inboundEndpoint.request(30000L);

    return muleMessage;
}

I've just checked and I can batch on the same file locally, so it's an issue with this endpoint or its configuration. Can I configure this endpoint to put the file in a temp directory and read it from there?

Upvotes: 0

Views: 2711

Answers (3)

Marcos
Marcos

Reputation: 93

In anypoint Studio Mule -> "Clear Application Data" worked for me as @rbutenuth said

Upvotes: 0

cerestorm
cerestorm

Reputation: 53

We found out the issue in the end.

We were using a session variable of an Immutable Map type, and although not used anywhere around the batch process, was causing the above error.

After removing this variable as part of the batch Input stage there were no further issues.

Upvotes: 0

Roger Butenuth
Roger Butenuth

Reputation: 546

The batch job splits the original payload (must be Collection or Iterator) serializes the splitted messages (including payload) into its persistent batch queue.

Is your message payload (after split) serializable?

Another problem is the persistence: Try to check "Clear Application Data" in the run configuration. When that does not help, delete the directory /mule/.mule/.mule/ in your workspace.

You probably know the batch job documentation:

https://docs.mulesoft.com/mule-user-guide/v/3.8/batch-processing

Upvotes: 1

Related Questions