diff --git a/2021.11.16.txt b/2021.11.16.txt
deleted file mode 100644
index 01761d5..0000000
--- a/2021.11.16.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.release11;
-
-import com.mysql.cj.jdbc.MysqlDataSource;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.command.ActiveMQMapMessage;
-import org.apache.camel.*;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jms.JmsComponent;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.support.SimpleRegistry;
-import org.apache.log4j.BasicConfigurator;
-
-public class Main {
-
- public static void main(String[] args) throws Exception {
-
- //MyBuilder myBuilder = new MyBuilder();
- //myBuilder.doRandomMaterials();
- //myBuilder.doRandomPackage();
-
- //to("log:?level=INFO&showHeaders=true&showBody=true")
-
- MysqlDataSource source = new MysqlDataSource();
- String jacek = "jdbc:mysql://10.101.111.19:3306/camel_db";
- source.setURL(jacek);
- source.setUser("root");
- source.setPassword("admin");
- SimpleRegistry registry = new SimpleRegistry();
- registry.bind("source", MysqlDataSource.class, source);
- CamelContext context = new DefaultCamelContext(registry);
- BasicConfigurator.configure();
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://10.101.111.19:8088");
- connectionFactory.setUserName("admin");
- connectionFactory.setPassword("admin");
- context.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
-
- DAO myFunctions = new DAO();
-
-
-
-
-
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
-
- from("direct:start")
- .setBody(constant("SELECT * FROM material LIMIT 10"))
- .to("jdbc:source")
- .split(body())
- .to("activemq:queue:material");
-
- from("activemq:queue:material")
- .split(body())
- //.bean(myFunctions, "getId")
- .setHeader("id", simple("${body[id]}"))
- .setBody(constant("SELECT * FROM package WHERE material_id = :?id"))
- .to("jdbc:source?useHeadersAsParameters=true")
- .to("activemq:queue:materialPackage");
- //.to("log:?level=INFO&showBody=true");
-
- }
- });
-
- context.start();
- ProducerTemplate template = context.createProducerTemplate();
- template.sendBody("direct:start", null);
- Thread.sleep(1000);
- //template.setDefaultEndpointUri("activemq:queue:material");
-
- context.stop();
- }
-}
diff --git a/pom.xml b/pom.xml
index dff4614..e27c38b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,73 @@
3.12.0
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 3.0.0
+
+
+
+ org.apache.camel.springboot
+ camel-jaxb-starter
+ 3.12.0
+
+
+
+
+ javax.activation
+ activation
+ 1.1
+
+
+
+
+ org.glassfish.jaxb
+ jaxb-runtime
+ 2.3.1
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ jaxb2-maven-plugin
+ 2.5.0
+
+
+ xsd-to-java
+
+ xjc
+
+
+
+
+
+ ${basedir}/src/main/resources/material.xsd
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 17
+ 17
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/release11/Main.java b/src/main/java/com/release11/Main.java
index 963b31a..4e995f6 100644
--- a/src/main/java/com/release11/Main.java
+++ b/src/main/java/com/release11/Main.java
@@ -2,13 +2,16 @@ package com.release11;
import com.mysql.cj.jdbc.MysqlDataSource;
import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.command.ActiveMQMapMessage;
import org.apache.camel.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.SimpleRegistry;
import org.apache.log4j.BasicConfigurator;
+import org.apache.camel.converter.jaxb.JaxbDataFormat;
+
+import javax.xml.bind.*;
+
public class Main {
@@ -27,6 +30,24 @@ public class Main {
source.setPassword("admin");
SimpleRegistry registry = new SimpleRegistry();
registry.bind("source", MysqlDataSource.class, source);
+
+
+ //jax.marshal(Exchange ,jax,);
+ //registry.bind("jax", JaxbDataFormat.class, XMLDataFormat);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
CamelContext context = new DefaultCamelContext(registry);
BasicConfigurator.configure();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://10.101.111.19:8088");
@@ -34,16 +55,16 @@ public class Main {
connectionFactory.setPassword("admin");
context.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
- DAO myFunctions = new DAO();
-
-
-
-
-
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
+ JaxbDataFormat XMLDataFormat = new JaxbDataFormat();
+ //XMLDataFormat.setSchemaLocation("/home/igor/Documents/Jacek/jacek-and-igor/src/main/resources/material.xsd");
+ XMLDataFormat.setContextPath("generated");
+ JAXBContext jaxbContext = JAXBContext.newInstance(generated.MaterialType.class);
+ XMLDataFormat.setContext(jaxbContext);
+
from("direct:start")
.setBody(constant("SELECT * FROM material"))
.to("jdbc:source")
@@ -56,16 +77,56 @@ public class Main {
.to("jdbc:source?useHeadersAsParameters=true");
from("activemq:queue:material")
- .enrich("direct:getPackages",new MyAggregator())
+ .enrich("direct:getPackages", new MyAggregator())
.to("activemq:queue:materialPackage")
.to("log:?level=INFO&showBody=true");
+ from("direct:test")
+ .setBody(constant("SELECT * FROM material LIMIT 1"))
+ .to("jdbc:source")
+ .split(body())
+ .to("activemq:queue:materialTest");
+
+ from("activemq:queue:materialTest")
+ .marshal(XMLDataFormat)
+ .to("activemq:queue:test");
+
+
+
+ from("direct:pretty")
+ .setBody(constant("" +
+ "\n" +
+ " 7\n" +
+ " A1\n" +
+ " LEGO 17272\n" +
+ " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n" +
+ " false\n" +
+ " \n" +
+ " 11988\n" +
+ " 80975098498590834\n" +
+ " pcs\n" +
+ " 17x17x17\n" +
+ " Lorem ipsum dolor sit amet, consectetur adipiscing elit\n" +
+ " \n" +
+ " \n" +
+ " 118\n" +
+ " 877854875843774\n" +
+ " pcs\n" +
+ " 20x20x20\n" +
+ " \n" +
+ "\n"))
+ .unmarshal()
+ .jaxb("generated")
+ .to("activemq:queue:test")
+ .to("log:?level=INFO&showBody=true");
+
+
}
});
context.start();
ProducerTemplate template = context.createProducerTemplate();
- template.sendBody("direct:start", null);
+ template.sendBody("direct:pretty", null);
Thread.sleep(1000);
//template.setDefaultEndpointUri("activemq:queue:material");
diff --git a/src/main/resources/material.xsd b/src/main/resources/material.xsd
index 0701eee..9bedbd1 100644
--- a/src/main/resources/material.xsd
+++ b/src/main/resources/material.xsd
@@ -3,6 +3,8 @@
+
+
@@ -11,7 +13,7 @@
-
+
@@ -27,8 +29,9 @@
+
-
+
diff --git a/target/classes/com/release11/Main$1.class b/target/classes/com/release11/Main$1.class
index 0941cc6..d2bd461 100644
Binary files a/target/classes/com/release11/Main$1.class and b/target/classes/com/release11/Main$1.class differ
diff --git a/target/classes/com/release11/Main.class b/target/classes/com/release11/Main.class
index 99c1953..1942bd6 100644
Binary files a/target/classes/com/release11/Main.class and b/target/classes/com/release11/Main.class differ
diff --git a/target/classes/com/release11/MyAggregator.class b/target/classes/com/release11/MyAggregator.class
index 0897f6a..4375f34 100644
Binary files a/target/classes/com/release11/MyAggregator.class and b/target/classes/com/release11/MyAggregator.class differ
diff --git a/target/classes/material.xsd b/target/classes/material.xsd
index 0701eee..9bedbd1 100644
--- a/target/classes/material.xsd
+++ b/target/classes/material.xsd
@@ -3,6 +3,8 @@
+
+
@@ -11,7 +13,7 @@
-
+
@@ -27,8 +29,9 @@
+
-
+