• Post Reply Bookmark Topic Watch Topic
  • New Topic

print all docs togather without interruption from other computers  RSS feed

 
Dhamayanthi Karuppanan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done a coding to print the reports from java (its basically a till machine and printing bills) and that is working fine. But the problem is, if any other Till machine sends the document to print, the printer will just get the job and does and finally it is kinda merging of papers from one till to other. I hope Im explaining the problem clearly. For ex. Till Machines t1 and t2; both printing 3 sets of doc as doc1 - 3 pages , doc2-2pages and doc3-3pages.

now the printer prints in the following order:
t1 -> doc1-3pages
t2 -> doc1-3pages
t2 -> doc2-2pages
t1 -> doc2-2pages
t2 -> doc3-3pages
t1 -> doc3-3pages

basically it does not follow any order, but it takes how it reaches printer from till machines. So, I want to synchronize this and in one shot, it should print from t1 and it should complete, then should it should go for t2 and goes on...

Is there any solution that I can implement in java.
Thank you for your time!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure you can control a printer's queue mechanism from Java; maybe look into the OS's mechanisms for doing so.

Another possibility would be to submit all your print jobs to a queue under your control, and feed them into the printer in the order you want.
 
Istvan Kovacs
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think no print queue manager will be intelligent enough to figure out that a client is not done yet, so it has to delay printing of other clients' documents. Is there no way to send those documents as a single print job from each client?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or just combine into a single file and print that.
 
Dhamayanthi Karuppanan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies. Yes! since these are reports and based on conditions these will get called. Grouping it in a single file is not possible.
but how i can group it in single printer job?
 
Istvan Kovacs
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I meant by 'group into a single job' was that you submit them as one. You may have to artificially create a single file from the 3 reports that you discard after printing.
The idea is that since you cannot start printing the first report until you have the last one, it's no use sending it (the 1st one) to the printer until you have all of them. I don't know your requirements, you may have to keep your generated reports as separate files and store them on disk or email them, but you'll have to combine them for printing.

You could go and create your own print service (via which all clients can print) that can be configured with a timeout (knowing that generating all reports takes at most 3 minutes, don't start printing a client's first report before that timeout, letting the other reports arrive, then print them all at once), but that will introduce delays. Or if you know you always print 3 reports from each client, start counting the jobs submitted by each client, and only start printing when one of them has 3 reports ready, delay the others while dealing with this one even if they also have 3 reports). But this is clumsy.

You could have clients pass around a token; whoever has the token has the right to print. However, you'll have to handle node failures (one of the clients gets the token then crashes, after a time the others need to generate a new token and one of them can start printing). Complicated stuff.

I think you'll be best off by generating the reports, saving/emailing them as you need, generate a combined report, and send it to the printer as a single file/job. That's simple and efficient (you don't need to delay printing one client's reports while waiting for another client's remaining reports to arrive - once the combined report is there, it can be enqueued and printed as soon as the printer is ready; the operating system will take care of that for you).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!