As Available as of Camel 2.14
The barcode data format is based on the zxing library. The goal of this component is to create a barcode image from a String (marshal) and a String from a barcode image (unmarshal). You're free to use all features that zxing offers.
Dependencies
To use Bindy the barcode data format in your camel routes you need to add the a dependency on camel-barcode which implements this data format.
...
Code Block |
---|
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-barcode</artifactId> <version>x.x.x</version> </dependency> |
...
Using the Java DSL
First you have to initialize the barcode data fomat class. You can use the default constructor, or one of parameterized (see JavaDoc). The default values are:
...
Code Block |
---|
// QR-Code default DataFormat code = new BarcodeDataFormat(); |
If you want to use zxing hints, you can use the 'addToHintMap' method of your BarcodeDataFormat instance:
Code Block |
---|
code.addToHintMap(DecodeHintType.TRY_HARDER, Boolean.true);
|
For possible hints, please consult the xzing documentation.
Marshalling
Code Block |
---|
from("direct://code") .marshal(code) .to("file://barcode_out"); |
...
Code Block |
---|
from("file://barcode_in?noop=true") .unmarshal(code1code) // for unmarshalling, the instance doesn't matter .to("log:OUT") .to("mock:out"); |
If you'll paste the QR-Code image above into the 'barcode_in' folder, you should find 'This is a testmessage!
' inside the mock. You can find the barcode data format as header variable:
Name | Type | Description |
---|---|---|
BarcodeFormat | String | Value of com.google.zxing.BarcodeFormat. |