Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I use a if/do loop to emulate a FIFO line for my web service?

 
Koldo Urrutia
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey

Since I couldnt get my web service to really support multiple users, Ive thought of simply implementing a FIFO kinda of queue like this:

(The code is made up on the spot right now. Therefore, ; may be missing, some variable declared wrong, etc. Ignore that. Just concentrate on the logic)





Would this work when multiple users call the web services at the same time to make the queue?

Thanks



 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I couldnt get my web service to really support multiple users,


A correctly designed web service should be able to support multiple users - what exactly was the design problem you could not overcome?

Your proposed code looks like you have an ordinary web application, not a SOAP or RESTful web service.

What are the clients for your service using to access it?

Bill
 
Koldo Urrutia
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My main problem (first off) is that I copy and move (therefore delete) a certain file named the exactly the same for each client I called but structured differently internally depending on things sent from the client.


The client is a CMS: Magento. There is a program there and it basically sends me points of Xs and Ys and generates a certain program which is always named the same way (no date, id order, nothing and no, this cannot be changed under no way, shape or form) which is then moved to somewhere else (a file server to be exact)

The problem is that when 2 users call the web services at the same time, there is a point where both users "use" that file (creating it, deleting it, copying it, etc) that they get mixed up with each other and errors pop up.
 
Koldo Urrutia
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The loop works for 2 users but I tried 6 (3 browsers on each PC) and it crashed....

Main problem is when trying to create/move/delete/copy/zip files with the same name from what I can see.....
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How much time does the create/copy/delete cycle take?

Could you not encapsulate all of the file operations in a single object and synchronize access to that object?

(My sympathy for having to deal with such a horrible design)

Bill
 
Koldo Urrutia
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:How much time does the create/copy/delete cycle take?

Could you not encapsulate all of the file operations in a single object and synchronize access to that object?

(My sympathy for having to deal with such a horrible design)

Bill

The time is (estimated) about 15-20 seconds; It does a FTP transfer as well so.....

Lets say for example the code is something such as (again ignore things like missing ";" or uncorrect functions):



How would I correctly do what you mentioned about "encapsulate all of the file operations in a single object and synchronize access to that object"? That is doable.
 
Koldo Urrutia
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No ideas to those lines on how to do it or correctly incapsulate them in syncronized objects???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic