Skip to content

Commit a74eea0

Browse files
committed
feat: readme update for xml record builder
Signed-off-by: Joel Hanson <joelhanson025@gmail.com>
1 parent 4ba2e41 commit a74eea0

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
@@ -388,6 +388,92 @@ Once the MQ source connector has delivered messages to Kafka with exactly-once s
388388
The MQ source connector is designed to fail on start-up in certain cases to ensure that exactly-once delivery is not compromised.
389389
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.
390390

391+
## Using the XML Record Builder
392+
393+
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.
394+
395+
### Prerequisites
396+
397+
Download and install the XML converter JAR:
398+
399+
```bash
400+
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
401+
402+
mvn install:install-file \
403+
-Dfile=kafka-connect-xml-converter-{VERSION}-jar-with-dependencies.jar \
404+
-DgroupId=com.ibm.eventstreams.kafkaconnect.plugins \
405+
-DartifactId=kafka-connect-xml-converter \
406+
-Dversion={VERSION} \
407+
-Dpackaging=jar
408+
```
409+
410+
Or, if using Maven:
411+
412+
```xml
413+
<dependency>
414+
<groupId>com.ibm.eventstreams.kafkaconnect.plugins</groupId>
415+
<artifactId>kafka-connect-xml-converter</artifactId>
416+
<version>{VERSION}</version>
417+
</dependency>
418+
```
419+
420+
Replace `{VERSION}` with the desired version number.
421+
422+
---
423+
424+
### Connector Configuration
425+
426+
To enable the XML record builder, add the following properties to your connector configuration:
427+
428+
```java
429+
connectorConfigProps.put("mq.record.builder", "com.ibm.eventstreams.kafkaconnect.plugins.xml.XmlMQRecordBuilder");
430+
connectorConfigProps.put("mq.record.builder.schemas.enable", "true");
431+
connectorConfigProps.put("mq.record.builder.root.element.name", "Person");
432+
connectorConfigProps.put("mq.record.builder.xsd.schema.path", "person.xsd");
433+
```
434+
435+
- `mq.record.builder`: Class name of the XML record builder.
436+
- `mq.record.builder.schemas.enable`: Enables schema generation and validation.
437+
- `mq.record.builder.root.element.name`: The expected root element name in the XML payload.
438+
- `mq.record.builder.xsd.schema.path`: Path to the XSD schema file used for validation.
439+
440+
---
441+
442+
### Example XML Message (`person.xml`)
443+
444+
```xml
445+
<?xml version="1.0" encoding="UTF-8"?>
446+
<Person>
447+
<Name>John Doe</Name>
448+
<Age>30</Age>
449+
<Email>john.doe@example.com</Email>
450+
</Person>
451+
```
452+
453+
---
454+
455+
### Example XSD Schema (`person.xsd`)
456+
457+
```xml
458+
<?xml version="1.0" encoding="UTF-8"?>
459+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
460+
<xs:element name="Person">
461+
<xs:complexType>
462+
<xs:sequence>
463+
<xs:element name="Name" type="xs:string" />
464+
<xs:element name="Age" type="xs:int" />
465+
<xs:element name="Email" type="xs:string" />
466+
</xs:sequence>
467+
</xs:complexType>
468+
</xs:element>
469+
</xs:schema>
470+
```
471+
472+
- The `XmlMQRecordBuilder` is packaged within the Kafka XML converter JAR.
473+
- Ensure that the XSD file (`person.xsd`) is accessible to the connector runtime, e.g., mounted in the container or available on the classpath.
474+
- Poison messages due to XML parsing or schema validation errors can be routed to a dead letter queue (DLQ) if configured.
475+
476+
391477
## Troubleshooting
392478

393479
### Connector in a `FAILED` state

0 commit comments

Comments
 (0)