modified pom and some classes
This commit is contained in:
		| @@ -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(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										67
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -51,6 +51,73 @@ | ||||
|             <version>3.12.0</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <dependency> | ||||
|             <groupId>javax.xml.bind</groupId> | ||||
|             <artifactId>jaxb-api</artifactId> | ||||
|             <version>2.3.1</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.sun.xml.bind</groupId> | ||||
|             <artifactId>jaxb-impl</artifactId> | ||||
|             <version>3.0.0</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <dependency> | ||||
|             <groupId>org.apache.camel.springboot</groupId> | ||||
|             <artifactId>camel-jaxb-starter</artifactId> | ||||
|             <version>3.12.0</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <!-- https://mvnrepository.com/artifact/javax.activation/activation --> | ||||
|         <dependency> | ||||
|             <groupId>javax.activation</groupId> | ||||
|             <artifactId>activation</artifactId> | ||||
|             <version>1.1</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime --> | ||||
|         <dependency> | ||||
|             <groupId>org.glassfish.jaxb</groupId> | ||||
|             <artifactId>jaxb-runtime</artifactId> | ||||
|             <version>2.3.1</version> | ||||
|         </dependency> | ||||
|  | ||||
|     </dependencies> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
|                 <groupId>org.codehaus.mojo</groupId> | ||||
|                 <artifactId>jaxb2-maven-plugin</artifactId> | ||||
|                 <version>2.5.0</version> | ||||
|                 <executions> | ||||
|                     <execution> | ||||
|                         <id>xsd-to-java</id> | ||||
|                         <goals> | ||||
|                             <goal>xjc</goal> | ||||
|                         </goals> | ||||
|                     </execution> | ||||
|                 </executions> | ||||
|                 <configuration> | ||||
|                     <sources> | ||||
|                         <source>${basedir}/src/main/resources/material.xsd</source> | ||||
|                     </sources> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|             <plugin> | ||||
|                 <groupId>org.apache.maven.plugins</groupId> | ||||
|                 <artifactId>maven-compiler-plugin</artifactId> | ||||
|                 <configuration> | ||||
|                     <source>17</source> | ||||
|                     <target>17</target> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|         </plugins> | ||||
|     </build> | ||||
|  | ||||
|  | ||||
| </project> | ||||
| @@ -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("<?xml version='1.0'?>" + | ||||
|                                 "<material>\n" + | ||||
|                                 "    <material_number>7</material_number>\n" + | ||||
|                                 "    <material_type>A1</material_type>\n" + | ||||
|                                 "    <material_name>LEGO 17272</material_name>\n" + | ||||
|                                 "    <description>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</description>\n" + | ||||
|                                 "    <is_deleted>false</is_deleted>\n" + | ||||
|                                 "    <packages>\n" + | ||||
|                                 "        <package_number>11988</package_number>\n" + | ||||
|                                 "        <ean>80975098498590834</ean>\n" + | ||||
|                                 "        <unit_of_measure>pcs</unit_of_measure>\n" + | ||||
|                                 "        <dimension>17x17x17</dimension>\n" + | ||||
|                                 "        <description>Lorem ipsum dolor sit amet, consectetur adipiscing elit</description>\n" + | ||||
|                                 "    </packages>\n" + | ||||
|                                 "    <packages>\n" + | ||||
|                                 "        <package_number>118</package_number>\n" + | ||||
|                                 "        <ean>877854875843774</ean>\n" + | ||||
|                                 "        <unit_of_measure>pcs</unit_of_measure>\n" + | ||||
|                                 "        <dimension>20x20x20</dimension>\n" + | ||||
|                                 "    </packages>\n" + | ||||
|                                 "</material>\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"); | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,8 @@ | ||||
|  | ||||
|     <xs:complexType name="package"> | ||||
|         <xs:sequence> | ||||
|             <xs:element name="id" type="xs:int"/> | ||||
|             <xs:element name="material_id" type="xs:int"/> | ||||
|             <xs:element name="package_number" type="xs:int"/> | ||||
|             <xs:element name="ean" type="xs:string"/> | ||||
|             <xs:element name="unit_of_measure" type="xs:string"/> | ||||
| @@ -11,7 +13,7 @@ | ||||
|         </xs:sequence> | ||||
|     </xs:complexType> | ||||
|  | ||||
|     <xs:simpleType name="material_type" final="restriction"> | ||||
|     <xs:simpleType name="material_typeType" final="restriction"> | ||||
|         <xs:restriction base="xs:string"> | ||||
|             <xs:enumeration value="A1"/> | ||||
|             <xs:enumeration value="A2"/> | ||||
| @@ -27,8 +29,9 @@ | ||||
|  | ||||
|     <xs:complexType name="materialType"> | ||||
|         <xs:sequence> | ||||
|             <xs:element name="id" type="xs:int"/> | ||||
|             <xs:element name="material_number" type="xs:int"/> | ||||
|             <xs:element name="material_type" type="material_type"/> | ||||
|             <xs:element name="material_type" type="material_typeType"/> | ||||
|             <xs:element name="material_name" type="xs:string"/> | ||||
|             <xs:element name="description" type="xs:string"/> | ||||
|             <xs:element name="is_deleted" type="xs:boolean"/> | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -3,6 +3,8 @@ | ||||
|  | ||||
|     <xs:complexType name="package"> | ||||
|         <xs:sequence> | ||||
|             <xs:element name="id" type="xs:int"/> | ||||
|             <xs:element name="material_id" type="xs:int"/> | ||||
|             <xs:element name="package_number" type="xs:int"/> | ||||
|             <xs:element name="ean" type="xs:string"/> | ||||
|             <xs:element name="unit_of_measure" type="xs:string"/> | ||||
| @@ -11,7 +13,7 @@ | ||||
|         </xs:sequence> | ||||
|     </xs:complexType> | ||||
|  | ||||
|     <xs:simpleType name="material_type" final="restriction"> | ||||
|     <xs:simpleType name="material_typeType" final="restriction"> | ||||
|         <xs:restriction base="xs:string"> | ||||
|             <xs:enumeration value="A1"/> | ||||
|             <xs:enumeration value="A2"/> | ||||
| @@ -27,8 +29,9 @@ | ||||
|  | ||||
|     <xs:complexType name="materialType"> | ||||
|         <xs:sequence> | ||||
|             <xs:element name="id" type="xs:int"/> | ||||
|             <xs:element name="material_number" type="xs:int"/> | ||||
|             <xs:element name="material_type" type="material_type"/> | ||||
|             <xs:element name="material_type" type="material_typeType"/> | ||||
|             <xs:element name="material_name" type="xs:string"/> | ||||
|             <xs:element name="description" type="xs:string"/> | ||||
|             <xs:element name="is_deleted" type="xs:boolean"/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user