Skip to content

Commit b4e1591

Browse files
authored
docs: readme update for xml record builder (#152)
Signed-off-by: Joel Hanson <joel.hanson2@ibm.com>
1 parent 2d832c2 commit b4e1591

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,92 @@ Once the MQ source connector has delivered messages to Kafka with exactly-once s
408408
The MQ source connector is designed to fail on start-up in certain cases to ensure that exactly-once delivery is not compromised.
409409
In some of these failure scenarios, it will be necessary for an MQ administrator to remove messages from the exactly-once state queue before the MQ source connector can start up and begin to deliver messages from the source queue again. In these cases, the MQ source connector will have the `FAILED` status and the Kafka Connect logs will describe any required administrative action.
410410

411+
## Using the XML Record Builder
412+
413+
The MQ Source Connector now supports processing JMS messages using an XML record builder. This builder parses XML payloads, validates them against an XSD schema, and produces Kafka records with structured data.
414+
415+
### Prerequisites
416+
417+
Download and install the XML converter JAR:
418+
419+
```bash
420+
curl -L -o kafka-connect-xml-converter-{VERSION}.jar https://github.com/ibm-messaging/kafka-connect-xml-converter/releases/download/v{VERSION}/kafka-connect-xml-converter-{VERSION}-jar-with-dependencies.jar
421+
422+
Or, if using Maven:
423+
424+
mvn install:install-file \
425+
-Dfile=kafka-connect-xml-converter-{VERSION}-jar-with-dependencies.jar \
426+
-DgroupId=com.ibm.eventstreams.kafkaconnect.plugins \
427+
-DartifactId=kafka-connect-xml-converter \
428+
-Dversion={VERSION} \
429+
-Dpackaging=jar
430+
```
431+
432+
```xml
433+
<dependency>
434+
<groupId>com.ibm.eventstreams.kafkaconnect.plugins</groupId>
435+
<artifactId>kafka-connect-xml-converter</artifactId>
436+
<version>{VERSION}</version>
437+
</dependency>
438+
```
439+
440+
Replace `{VERSION}` with the desired version number.
441+
442+
---
443+
444+
### Connector Configuration
445+
446+
To enable the XML record builder, add the following properties to your connector configuration:
447+
448+
```java
449+
"mq.record.builder": "com.ibm.eventstreams.kafkaconnect.plugins.xml.XmlMQRecordBuilder";
450+
"mq.record.builder.schemas.enable": "true";
451+
"mq.record.builder.root.element.name": "Person";
452+
"mq.record.builder.xsd.schema.path": "/path/to/person.xsd";
453+
```
454+
455+
- `mq.record.builder`: Class name of the XML record builder.
456+
- `mq.record.builder.schemas.enable`: Enables schema generation and validation.
457+
- `mq.record.builder.root.element.name`: The expected root element name in the XML payload.
458+
- `mq.record.builder.xsd.schema.path`: Path to the XSD schema file used for validation.
459+
460+
---
461+
462+
### Example XML Message (`person.xml`)
463+
464+
```xml
465+
<?xml version="1.0" encoding="UTF-8"?>
466+
<Person>
467+
<Name>John Doe</Name>
468+
<Age>30</Age>
469+
<Email>john.doe@example.com</Email>
470+
</Person>
471+
```
472+
473+
---
474+
475+
### Example XSD Schema (`person.xsd`)
476+
477+
```xml
478+
<?xml version="1.0" encoding="UTF-8"?>
479+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
480+
<xs:element name="Person">
481+
<xs:complexType>
482+
<xs:sequence>
483+
<xs:element name="Name" type="xs:string" />
484+
<xs:element name="Age" type="xs:int" />
485+
<xs:element name="Email" type="xs:string" />
486+
</xs:sequence>
487+
</xs:complexType>
488+
</xs:element>
489+
</xs:schema>
490+
```
491+
492+
- The `XmlMQRecordBuilder` is packaged within the Kafka XML converter JAR.
493+
- Ensure that the XSD file (`person.xsd`) is accessible to the connector runtime, e.g., mounted in the container or available on the classpath.
494+
- Poison messages due to XML parsing or schema validation errors can be routed to a dead letter queue (DLQ) if configured.
495+
496+
411497
## Troubleshooting
412498
413499
### Connector in a `FAILED` state

0 commit comments

Comments
 (0)