Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No ideas to those lines on how to do it or correctly incapsulate them in syncronized objects???
 
reply
    Bookmark Topic Watch Topic
  • New Topic