Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
nvtd4000
Contributor III
Contributor III

Is storing data in globalmap is safe in Rest service job

I am using Talend Studio (Big data platform) 7.3.1. I am developing a Rest service job that need to handle 100 requests per second. In the job, I store data in GlobalMap.

Ex: globalMap.put("userId",userId) and globaMap.get("userId")

My question is :

  1. When multiple requests come at the same time, I guess this job will create multiple instances to handle multiple requests. Does write (put) operation to globalmap of one instance will be messed with write operation to globalmap of other instances?

 

. Ex: instance1 write "david" to globalMap.userId, Instance2 write "Tom" to globalmap.userId. Is there a scenarios that instance1 get the value "Tom" in userId

 

. Ex: multiple instances write data to globalMap.userId. Is there any race condition happens?

 

2.In order to pass data from parent to subjob. Is it the best way to do that?

Labels (4)
1 Reply
Anonymous
Not applicable

Hello

This is answered by our developer in another question:

 

It’s been asked many times about Thread Safety in ESB in Studio.

I have run few test and the conclusion is

 

Context are not thread safe. 

GlobalMap is thread safe. 

 

If we look in detail of code generated ,

 

Context and globalMap both are used on class level inside a talendJOb but on RestRequest a new globalMap is created.

 

Hope it helps!

 

Regards

Shong