DBZ-4232 Fix OutboxEvent entity not found

This commit is contained in:
Chris Cranford 2021-11-29 18:50:33 -05:00 committed by Chris Cranford
parent 487f956d16
commit 220d20adba
5 changed files with 42 additions and 4 deletions

View File

@ -1 +0,0 @@
io.debezium.outbox.quarkus.deployment.AdditionalJaxbMappingProducerImpl

View File

@ -28,6 +28,12 @@
<artifactId>quarkus-smallrye-opentracing</artifactId>
<optional>true</optional>
</dependency>
<!-- Needed specifically for AdditionalJaxbMappingProducerImpl usage -->
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>2.4.0.Final</version>
</dependency>
<!-- Needed primarily for @Incubating annotation -->
<dependency>
<groupId>io.debezium</groupId>
@ -91,10 +97,16 @@
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources-filtered</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<includes>
<!-- Inject version information into the extension's YAML automatically -->
<include>**/quarkus-extension.yaml</include>
<include>**/*</include>
</includes>
</resource>
</resources>

View File

@ -3,7 +3,7 @@
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.outbox.quarkus.deployment;
package io.debezium.outbox.quarkus.internal;
import static io.debezium.outbox.quarkus.internal.OutboxConstants.OUTBOX_ENTITY_HBMXML;
@ -16,11 +16,16 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.SourceType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
@ -74,6 +79,10 @@ public Collection<MappingDocument> produceAdditionalMappings(MetadataImplementor
try (BufferedInputStream bis = new BufferedInputStream(bais)) {
final Binding<?> jaxbBinding = mappingBinder.bind(bis, origin);
final JaxbHbmHibernateMapping mapping = (JaxbHbmHibernateMapping) jaxbBinding.getRoot();
logOutboxMapping(mapping);
LOGGER.info("Contributed XML mapping for entity: {}", mapping.getClazz().get(0).getEntityName());
return Collections.singletonList(new MappingDocument(mapping, origin, buildingContext));
}
}
@ -95,4 +104,21 @@ private InputStream getOutboxHbmXmlStream() {
// Attempt to load the XML using the current class loader
return getClass().getResourceAsStream("/" + OUTBOX_ENTITY_HBMXML);
}
private void logOutboxMapping(JaxbHbmHibernateMapping mapping) {
try {
JAXBContext context = JAXBContext.newInstance(JaxbHbmHibernateMapping.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
final StringWriter writer = new StringWriter();
marshaller.marshal(mapping, writer);
LOGGER.debug("Debezium Outbox XML Mapping:\n{}", writer);
}
catch (JAXBException e) {
throw new RuntimeException("Failed to marshal Debezium Outbox XML mapping", e);
}
}
}

View File

@ -0,0 +1 @@
io.debezium.outbox.quarkus.internal.AdditionalJaxbMappingProducerImpl