From e0aa057fc09462f080c1f2fa60f9ea56f35c20a4 Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 18 Nov 2021 12:07:56 +0100 Subject: [PATCH] modified pom and some classes --- 2021.11.16.txt | 73 ---------------- pom.xml | 67 +++++++++++++++ src/main/java/com/release11/Main.java | 79 ++++++++++++++++-- src/main/resources/material.xsd | 7 +- target/classes/com/release11/Main$1.class | Bin 1987 -> 3932 bytes target/classes/com/release11/Main.class | Bin 2427 -> 2341 bytes .../classes/com/release11/MyAggregator.class | Bin 1319 -> 1319 bytes target/classes/material.xsd | 7 +- 8 files changed, 147 insertions(+), 86 deletions(-) delete mode 100644 2021.11.16.txt 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 0941cc6bd7751bf0f92c4a03e82d6d2f916e71a2..d2bd461d87f05cd387c7df023a46c8c6ce7bd83b 100644 GIT binary patch literal 3932 zcmb_fO>kS)75;8)kfJ=G6@M*(@KQozD~X?#*p+O{a%@MAoyf6k8z&(R=IXs``I+~l zydOs{rBM3c0xi%ky6>*jMW-`L2L`6AF4%U%f=xHwbfyc~cY5xVWXY061Fc5$e$GAT zo_oIY`#$>jdmjRr#BUNfguWR172JpW8J=~$vc@Z1-x8Y6ZDDDp(6kKUX)A6Rh?)8e z!~HqaF@roq-@xE{3~`2`E=k>Wc7zv@>^85Kw99n4$OAs-dNvOdh@mfzBMgVj!Vw-1 zgdu4UD0mPLF+AvtVAgd4Q4N-Pu*LA`KyjPzaLwXQSz8S}(;O zVTQ-{w$&DCbI;_~+HOT8@F*UO;c*3D!`B&}kfK$sYLlU+V`!JBug^5pG8}Qlodw4a zxT6b(;enfNCx{eH3`UfL9jDiz*mf;cIwKY#zg8L$!Ci_h1M4F+0({pWx+(AecyWC^D2DvwK>qW6C-D$ec zL>#9GyVXLmFuSIv)VYcCSn#0b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iggJ`LT?*IS* delta 734 zcmYjPOHUI~6#nk?HB2u>2W-{y6s&YW%0nKOR~1kJ5wvK_#tjMhHKL}Ltlcjm@l zVBEuINHiLaI~VE?@CUeb=f)V%3{7+v=R5bD?>xSH=X>j?2IcdgH}3&V;_eG&woQi2 zz;i}L&zkY7nW>lx6!?AM9Q6o@cWjd#5iL?!R-ke;qDdsA#Xt}tAC7aJz)6OPSayZP zo@8`1Gx+c4wzBbR@lhqKD+r>MqYdp0l38R(h<$fN+;cTIDmcZ_i7p2BRx$U4A=)i6 zk|qZc;W&eC@zJ&F))+$Kr#IwR(2G_d&emonlcl_2&g$Dn!7zLq)pst-x= zoX@b^;tLPC?jS9G@X1{T5?wwV>wy;xi*$++GD44b0JiU>uadRXKo6G4@wZ zW~dX6?^I1u6|tf=tM4rmYX`V!Va9HF`LLlnZ&Utl8b^S(ilGkuXu<%(7^K%7qL&;d zZv;~q#XQE4UZU$=$2fABK%RcW5~lx?SFXvsPR(plH^{D%FX1L`Ik6PhsNRmGutBI0 IOChB1FM`2`nE(I) diff --git a/target/classes/com/release11/Main.class b/target/classes/com/release11/Main.class index 99c1953dc6d3655e09f6735bb9f580d66b09c7b7..1942bd636c328ca565d22c6c6f347b88e11b1342 100644 GIT binary patch delta 542 zcmYL_-D(qI5Qd*G*<@pOg%FA~{zMO=2ZDs4RtYGA1l!tLO|`bxpRUQO(YA@3wOaqy zDhfiug9W_;FQ5q4DD(onACCm_O)B^uyfgE?GxN^O@BHU{_UE7PTfiyaY-G2RrJ+W9 zsT}x=zSs3DmGY$5S}s+x)JQsg2c^Qw}Q`hg1(3l9NNm_VMQCZf=rVejnHU@M{*ry@KeWAOZzylT)?O=&zHBqq{ z!@}0zr}&rcMFr~zwYg2s^%zZ1uzF0GftfN?(}i??+Vr@RWQh51-01TS!+*)T2-r=A zJvi)@_&#<~l((M}2ROn}PH>DW$92sSCKOF`Qu|kF6A`WON@k7syygRM`N+G${G;15 zDybuZjJP5XwUfg-0bT7<5{5h?sg?_@@K}4*sPlwXoho9Or##b5o~zzcTrRu!l?Of z)o+304i~u;B=y0b%L=F9Rf~B)`467ts>zhYG}nR;dck(NVUl+!Pz)^NaOW+D+buf1 z=2zxTX1}D2H>%GrEuLN|=Y6kIt|_)>H;WVD!H@8OdKuVeZrURx9+4=b2ur*pRa~-? zY#d!ht+e4ei7gnmQj+Lw9H2}^sx8cOS4iZtnn9;SdY^)?rdwYlJ-N!6WH_p?k&*4$ zCg(y#^(HyhPGgFs88ssls>v0NF0OxLriI^B{GUC+4&mG-%-z^T>0~!M*~4C0F?u*o zFDKYXlKt{5ePlVnI0x&v9AcJZJm3^{25B(FTRHMxp64UOZ8KvVf~iuIAsvGC;)_9> zcPwyEjKz4&ec{k#h{qxi#blZ(9!cL2{(heDRDMuH + + @@ -11,7 +13,7 @@ - + @@ -27,8 +29,9 @@ + - +