Apache Camel And Printing Producer - printing

This one should be simple but for the life of me I cannot figure out how to get it running. What I want to do is read files from a folder and send them to a printer.
So I had a look at the documentation for the printer component in Camel and it seemed straight forward.
I produced the following DSL route:
<camelContext trace="false" id="blueprintContext" xmlns="http://camel.apache.org/schema/blueprint">
<route id="printSpoolRoute">
<from uri="file:d:/printspool?delay=1000&move=.done/printed/${date:now:yyyyMMdd}/${file:onlyname.noext}_DONE_${date:now:yyyyMMddHHmmss}.${file:name.ext}&readLock=changed""/>
<to uri="lpr:localhost/default?flavor=DocFlavor.INPUT_STREAM&mimeType=AUTOSENSE&mediaSize=iso-a4"/>
</route>
</camelContext>
When I start it up I get the following exception:
[ Blueprint Extender: 1] BlueprintCamelContext ERROR Error occurred during starting Camel: CamelContext(blueprintContext) due Failed to create Producer for endpoint: Endpoint[lpr://localhost/default?flavor=DocFlavor.INPUT_STREAM&mediaSize=iso-a4&mimeType=AUTOSENSE]. Reason: java.lang.NullPointerException
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[lpr://localhost/default?flavor=DocFlavor.INPUT_STREAM&mediaSize=iso-a4&mimeType=AUTOSENSE]. Reason: java.lang.NullPointerException
If the exception had more detail I might be able to look for something so I suspect I made a mistake in the URI of the printing producer.
While I am looking at the URI of the printer producer I just wanted to check if my understanding of the URI is correct when using a network printer.
Let assume I want to produce documents on a network printer connected to a server call SRV-07 with a name of HP LaserJet 4104 will the following URI be correct:
<to uri="lpr:SRV-07/HP LaserJet 4104?flavor=DocFlavor.INPUT_STREAM&mimeType=AUTOSENSE&mediaSize=iso-a4"/>
I am worried about dashes and spaces in the name and someone that has worked with this component before could shed some light here.

Right leaving this here for reference.
Answer is that the mediaSize parameter must be specified according to the documentation found at this link. I had the parameter as iso-a4 instead of ISO_A4. Maybe the camel developers could give a little more descriptive exception here.
Also the question about the URI for network printers does work as I have specified.

Related

How to draw line with Microsoft POS Printer

I am using the Microsoft Point Of Service SDK and I am testing both in my application and the Sample provided with the SDK to try and print a Line with code similar to this:
posPrinter.DrawRuledLine(PrinterStation.Receipt, "0,500", LineDirection.Horizontal, 1, LineStyle.BrokenLine, 1);
I get this error:
POSControlException ErrorCode(Illegal) ExtendedErrorCode(0) occurred: Method DrawRuledLine threw an exception. Attempt was made to perform an illegal or unsupported operation with the device, or an invalid parameter value was used.
Microsoft POS has a tendency to throw very generic errors and I don't know what I am doing wrong. I had similar errors on other methods and it turned out it was because I was passing a parameter that didn't quite work, like a too big a width. But I have tested all kinds of combinations and this always fails. And there is no enough documentation on the parameters it receives.
What parameters do I need to pass to this method to draw a line? Is this the preferred way to draw a line with Microsoft POS?
Microsoft Point Of Service(part of the UnifiedPOS implementation) is an API with an abstract standard specification and does not have all the features of a real printer.
If your printer and the service object that runs it do not have DrawRuledLine functionality, you will get that error.
ErrorCode Enumeration (POS for .NET v1.12 SDK Documentation)
Illegal
An attempt was made to perform an illegal or unsupported operation with the device, or an invalid parameter value was used.
The presence or absence of the function can be confirmed in advance by checking the value of the CapRecRuledLine(CapSlpRuledLine for Slip stations) property.
If you want to draw a line on a receipt with this DrawRuledLine method, you need to switch to a printer and service object that supports that feature.
If you don't want to change the printer, you'll have to replace it with a character line.

xml to xml field attribute transformation using ESQL on message broker compute node

I am new to message broker development. I tried to convert source SOAP over xml file to target SOAP over xml file.On my message flow source message discarded to catch terminal.I am not able to find out the problem
my flow : MQINPUT NODE ---> COMPUTE NODE --> MQOUTPUT NODE
If any provide solution on this that may me helpful for me.
DECLARE soapenv CHARACTER 'SOAP-ENV';
SET OutputRoot.XMNLSC.soapenv:Envelope.soapenv:Body.params.ORIGIN_TYPE_CD = InputRoot.XMNLSC.soapenv:Envelope.soapenv:Body.params.originType;
**
Your first line is definitely wrong, but you should be able to see that from the exceptions you are getting.
The first line should be:
DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
An in the further lines the domain should be XMLNSC not XMNLSC.

How to implement a custom file parser in Google DataFlow for a Google Cloud Storage file

I have a custom file format in Google Cloud Storage and I want to read it from Google DataFlow.
I've implemented a Source and a Reader by subclassing FileBasedReader, but then I realized it didn't support reading from Google Cloud Storage (while FileBasedSink actually does...) so I'm not sure what's the best idea to solve that here...
I tried to subclass TextIO but I couldn't reach an end with that as it doesn't seem to be designed to be subclassed.
Any good idea on how to deal with that?
Thanks.
Update to reflect on the comments
File pattern used: gs://mybucket/my.json
Implemented the Source class from FileBasedSource:
MessageSource<T> extends FileBasedSource<T>
Implemented the Reader class (what I really care about here) from FileBasedReader:
MessageReader<T> extends FileBasedReader<T>
Process for reading is:
MySource source = // instantiate source
Pipeline p = Pipeline.create(options);
p.apply(TextIO.Read.from(options.getSource()).named("ReadFileData"))
.apply(ParDo.of(new DoFn<String, String>() {
And the getSource() comes from this command line parameter (verified correct):
--source=gs://${BUCKET_NAME}/my.json \
Am I missing anything?
2nd UPDATE
While running source.getEstimatedSizeBytes(options) it tells me no handler found?
java.io.IOException: Unable to find handler for gs://mybucket/my.json
at com.google.cloud.dataflow.sdk.util.IOChannelUtils.getFactory(IOChannelUtils.java:186)
at com.google.cloud.dataflow.sdk.io.FileBasedSource.getEstimatedSizeBytes(FileBasedSource.java:182)
at com.etc.TrackingDataPipeline.main(TrackingDataPipeline.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)
I thought the FileBasedSource was supposed to handle GCS?
From the stack trace you show in "2nd Update", it looks like you have called getEstimatedSizeBytes directly from your main() method. This is expected to lead to the error you see.
The standard URL scheme handlers are registered when a pipeline runner is constructed. In your example code, that would happen when you call Pipeline.create(options) (this calls PipelineRunner.fromOptions(options), where the standard handlers are registered).
If you want to have the standard URL schemes registered in a context other than running a pipeline, you can explicitly call IOChannelUtils.registerStandardIOFactories(). I should note that this is not a supported API, but reaching a bit "under the hood". As such, it may change at any time.

Write to the system's standard error in Progress

I am writing a small program in Progress that needs to write an error message to the system's standard error. What ways, simple if at all possible, can I use to print to standard error?
I am using OpenEdge 11.3.
When on Windows (10.2B+) you can use .NET:
System.Console:Error:WriteLine ("This is an error message") .
together with
prowin32 2> stderr.out
Progress doesn't provide a way to write to stderr - the easiest way I can think of is to output-through an external program that takes stdin and echoes it to stderr.
You could look into LOG-MANAGER:WRITE-MESSAGE. It won't log to standard output or standard error, but to a client-specific log. This log should be monitored in any case (specifically if the client is an application server).
From the documentation:
For an interactive or batch client, the WRITE-MESSAGE( ) method writes the log entries to the log file specified by the LOGFILE-NAME attribute or the Client Logging (-clientlog) startup parameter. For WebSpeed agents and AppServer servers, the WRITE-MESSAGE() method writes the log entries to the server log file. For DataServers, the WRITE-MESSAGE() method writes the log entries to the log file specified by the DataServer Logging (-dslog) startup parameter.
LOG-MANAGER:WRITE-MESSAGE("Got here, x=" + STRING(x), "DEBUG1").
Will write this in the log:
[04/12/05#13:19:19.742-0500] P-003616 T-001984 1 4GL DEBUG1 Got here, x=5
There are quite a lot of options regarding the LOG-MANAGER system, what messages to display, where the file is placed, etc.
There is no easy way, but in Unixen you can always do something like this using OUTPUT THROUGH (untested):
output through "cat >&2" no-echo unbuffered.
Alternatively -- and this is tested -- if you just want error messages from a batch-mode program to go to standard out then
output through "tee" ...
...definitely works.

Unmarshalling Error

I get an error whenever I try do a request to a SOAP service:
Unmarshalling Error: unexpected element (uri:"http://www.domain.com/ws/servicename/", local:"dummyArg"). Expected elements are <{}dummyArg>
The method that I'm calling has is defined as:
function GetTxServer(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): TxServer;
I have little experience with SOAP, and I couldn't find any useful information on this. Feel free to ask any question that might speed up the process in finding the issue.
I believe that the way that I am calling the function is not the correct way!
I'm using Delphi 2010, and I've called the method like so:
Response := GetTxServer.requestIVULoto(cm);
Use SoapUI (the free version is fine) to consume the WSDL and make sure that you can properly send a request to the server and get a response that makes sense. Then make a "mock" service in SoapUI, to act as the server. Send your Delphi requests to the mockservice (typically done by setting your endpoint to http://localhost:8089 or some such) so that you can inspect the XML that you're sending out. Now you can experiment and determine whether the problem is due to sending out bad requests, the server returning bad/unexpected results, trouble interpreting good results, etc..
Aside from that, I'd guess that you're failing to allocate or populate "cm" correctly. I assume that's your request object.
Also... big tip here....
Use the RIO_BeforeExecute event to debug this. At that point, the SOAPRequest is a string that you can inspect or dump to a file. So you can see what you're sending, without having to use SoapUI, Fiddler2, Wireshark, etc..

Resources