Unable to receive data using doThreadInvoke method

Hi,

I am trying to call a java service(JS2) from the java service (JS1). I am able to call the service but the parameter passed while calling are not received in the called service. Below is my code.

Java Service 1 Code

int i=0;
IData parentDoc = IDataFactory.create();
IDataCursor dp = parentDoc.getCursor();
IDataUtil.put(dp, “Test”, “Value”);

		try {
			[b]Service.doThreadInvoke("Jacob.multiThreading", "childService", parentDoc);[/b]
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Java Service 2 Code

String i =“”;
IDataCursor pipelineCursor = pipeline.getCursor();
IData parentDoc = IDataUtil.getIData(pipelineCursor, “parentDoc”);

	if ([b]parentDoc != null[/b]){
		IDataCursor tvCursor = parentDoc.getCursor();
		i = IDataUtil.getString(tvCursor, "Test");
		pipelineCursor.destroy();
	}

Always the if statement is failing since the parentDoc passed in JavaService 1 is not received in JavaService 2.

Can you please shed some light on this?

Regards,
Jacob B

parentDoc will be the whole pipeline in the called service. There, you should just extract the value passed as “Test”.

Hi,
Yes i am trying the same. But I see that parentDoc is null in the JavaService2.

Not sure why the parentDoc is null.

Regards,
Jacob

Hi,

Can anyone please suggest on this?

Hi,

It seems that in Java Service 1 you created an IData object and sent it as the input pipeline to Java Service 2 but in the later you are expecting that IData as an object in the input pipeline.

Maybe you should use:
Java Service 2 Code

String i =""; 
IDataCursor pipelineCursor = pipeline.getCursor(); 
//IData parentDoc = IDataUtil.getIData(pipelineCursor, "parentDoc"); 

//if (parentDoc != null){ 
//IDataCursor tvCursor = parentDoc.getCursor(); 
i = IDataUtil.getString(pipelineCursor , "Test"); // "Test" is already in the service pipeline
pipelineCursor.destroy(); 
//}

Yeah, it is working… Thanks

but i am sending input doc while calling the java service 2 right? Can i access it using separate cursor instead of pipeline cursor?

What was the issue when i call it again using a separate cursor?

Regards,
Jacob

Hi Jabob,

can you provide us the “Input/Ouptut” Tab for those services as a screenshot?

This might ease the explanation.

Regards,
Holger

As I said: if you specify a document as the parameter when calling doInvoke, then it will be available as “pipeline” in the called service. If you want to pass the document “parentDoc” in the pipeline, then create another IData, say “callPipeline”, put parentDoc there and then specify callPipeline as the parameter.

Issue is resolved. As mentioned by Gerardo and fml2 the data is available in pipeline, so we can access it directly.

Thank you all. :slight_smile:

Regards,
Jacob