Hi,

I’m using the Camel printer component to send PDF files to a print queue. When 
I configure the endpoint like this, the lpr command is executed twice with the 
-#2 parameter:
lpr://localhost/printer?copies=2&mediaSize=ISO_A4&flavor=DocFlavor.INPUT_STREAM

component.printer.PrinterProducer DEBUG Printer service printer name: printer
component.printer.PrinterOperations DEBUG Issuing Job 0 to Printer: printer
component.printer.PrinterOperations DEBUG Issuing Job 1 to Printer: printer
ERROR ID-47935-1516954952584-8-4
java.io.IOException: error=1 running: '/usr/bin/lpr' '-Pprinter' '-J file.pdf' 
'-#2' '-o media=A4 sides=one-sided' 
'/opt/tomcat/temp/javaprint7376295310894617090'
                /usr/bin/lpr: No file in print request.
javax.print.PrintException: java.io.IOException: error=1 running: 
'/usr/bin/lpr' '-PBriefing' '-J file.pdf' '-#2' '-o media=A4 sides=one-sided' 
'/opt/tomcat/temp/javaprint7376295310894617090'
                /usr/bin/lpr: No file in print request.
        at sun.print.UnixPrintJob$PrinterSpooler.run(UnixPrintJob.java:1017)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.print.UnixPrintJob.print(UnixPrintJob.java:608)
        at 
org.apache.camel.component.printer.PrinterOperations.print(PrinterOperations.java:109)
        at 
org.apache.camel.component.printer.PrinterOperations.print(PrinterOperations.java:99)
        at 
org.apache.camel.component.printer.PrinterProducer.print(PrinterProducer.java:57)
        at 
org.apache.camel.component.printer.PrinterProducer.process(PrinterProducer.java:51)
        at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
        at 
org.apache.camel.processor.SendDynamicProcessor$1.doInAsyncProducer(SendDynamicProcessor.java:124)
        at 
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:436)
        at 
org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:119)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
        at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
        at 
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
        at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
        at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
        at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
        at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
        at 
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
        at 
org.apache.camel.processor.MulticastProcessor.doProcessParallel(MulticastProcessor.java:827)
        at 
org.apache.camel.processor.MulticastProcessor.access$200(MulticastProcessor.java:85)
        at 
org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:320)
        at 
org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:305)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

The first job executes correctly, the second one fails because the input file 
is empty. Why is the lpr command executed twice? The -#2 parameter already 
schedules the desired number of copies.

I think the issue is caused by the following statement being inside the loop:
https://github.com/apache/camel/blob/3505e718db48cc0d8be5b47f6c4030c958d93a5f/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java#L99
 
<https://github.com/apache/camel/blob/3505e718db48cc0d8be5b47f6c4030c958d93a5f/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterOperations.java#L99>

I’m using Camel 2.18.1 on JDK8.

Best regards,

Robin


-- 


AVIO

Herkenrodesingel 8/D.3.01

3500 Hasselt

Belgium

T +32 11 72 10 30

www.avio.aero <http://www.aviobook.aero>

Avio - A Thales Group Company

The information contained in this message may be privileged and 
confidential and protected from disclosure. If the reader of this message 
is not the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, you are 
kindly requested to notify us immediately by replying to the message and 
deleting it from your computer. Any views or opinions presented in this 
email or any attachments are solely those of the author and do not 
necessarily represent those of Avio, or associated companies.

Reply via email to