aspose file tools*
The moose likes Web Services and the fly likes Can I use a if/do loop to emulate a FIFO line for my web service? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Can I use a if/do loop to emulate a FIFO line for my web service?" Watch "Can I use a if/do loop to emulate a FIFO line for my web service?" New topic
Author

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

Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
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

Joined: Mar 22, 2000
Posts: 12675
    
    5
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

Java Resources at www.wbrogden.com
Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
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

Joined: Dec 16, 2011
Posts: 85
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

Joined: Mar 22, 2000
Posts: 12675
    
    5
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

Joined: Dec 16, 2011
Posts: 85
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

Joined: Dec 16, 2011
Posts: 85
No ideas to those lines on how to do it or correctly incapsulate them in syncronized objects???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I use a if/do loop to emulate a FIFO line for my web service?
 
Similar Threads
locking issue
autoboxing and synchronized
Anyone know regular expressions?
return complex typ
Abstract Data Type for a Queue