project pushed
This commit is contained in:
		| @@ -43,20 +43,21 @@ public class Main { | ||||
|                 xmlDataFormat.setContextPath("generated"); | ||||
|                 JacksonDataFormat jacksonDataFormat = new JacksonDataFormat(ObjectFactory.class); | ||||
|                 jacksonDataFormat.setPrettyPrint(true); | ||||
|                 errorHandler(deadLetterChannel("activemq:queue:dead")); | ||||
|                 errorHandler(deadLetterChannel("activemq:queue:dead?transferExchange=true").maximumRedeliveries(3).redeliveryDelay(5000)); | ||||
|  | ||||
|                 from("direct:start") | ||||
|                         .setBody(constant("SELECT * FROM material")) | ||||
|                         .to("jdbc:source") | ||||
|                         .split(body()) | ||||
|                         .to("activemq:queue:RawMaterial"); | ||||
|                 //?acknowledgementModeName=CLIENT_ACKNOWLEDGE | ||||
|  | ||||
|                 from("direct:getPackages") | ||||
|                         .setHeader("material_id", simple("${body[id]}")) | ||||
|                         .setBody(simple("SELECT * FROM package WHERE material_id = :?material_id")) | ||||
|                         .to("jdbc:source?useHeadersAsParameters=true"); | ||||
|  | ||||
|                 from("activemq:queue:RawMaterial") | ||||
|                 from("activemq:queue:RawMaterial?acknowledgementModeName=CLIENT_ACKNOWLEDGE") | ||||
|                         .enrich("direct:getPackages", new MergeAggregator()) | ||||
|                         .process(new ValidatorProcess()) | ||||
|                         .choice() | ||||
| @@ -65,9 +66,7 @@ public class Main { | ||||
|                         .otherwise().marshal(xmlDataFormat).to("activemq:topic:Material") | ||||
|                         .to("log:?level=INFO&showBody=true"); | ||||
|  | ||||
|  | ||||
|  | ||||
|                 from("activemq:topic:Material?clientId=1&durableSubscriptionName=FilteredType") | ||||
|                     from("activemq:topic:Material?clientId=4&subscriptionDurable=true&subscriptionName=NAZWA") | ||||
|                         .filter().xpath("//material_type='A1' or //material_type='A2' or //material_type='A3'") | ||||
|                         .to("activemq:queue:FilteredType"); | ||||
|  | ||||
| @@ -77,14 +76,11 @@ public class Main { | ||||
|                         .marshal(jacksonDataFormat) | ||||
|                         .to("http:10.101.111.19:1080/api/json/material"); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|                 from("activemq:topic:Material?clientId=2&durableSubscriptionName=FilteredIsDeleted&acknowledgementModeName=CLIENT_ACKNOWLEDGE") | ||||
|                 from("activemq:topic:Material?clientId=5&subscriptionDurable=true&subscriptionName=NAZWA_DELETED") | ||||
|                         .filter().xpath("//is_deleted='false'") | ||||
|                         .to("activemq:queue:FilteredIsDeleted"); | ||||
|  | ||||
|                 from("activemq:queue:FilteredIsDeleted") | ||||
|                 from("activemq:queue:FilteredIsDeleted?acknowledgementModeName=CLIENT_ACKNOWLEDGE") | ||||
|                         .unmarshal(xmlDataFormat) | ||||
|                         .process(new CSVProcess()) | ||||
|                         .to("sftp:test@10.101.111.19:2222/upload/test?password=admin"); | ||||
| @@ -97,6 +93,8 @@ public class Main { | ||||
|         context.start(); | ||||
|         ProducerTemplate template = context.createProducerTemplate(); | ||||
|         template.sendBody("direct:start", null); | ||||
|  | ||||
|         Thread.sleep(50000); | ||||
|         context.stop(); | ||||
|     } | ||||
| } | ||||
| @@ -5,6 +5,8 @@ import generated.Package; | ||||
| import org.apache.camel.Exchange; | ||||
| import org.apache.camel.Processor; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public class CSVProcess implements Processor { | ||||
|  | ||||
|     @Override | ||||
| @@ -29,6 +31,9 @@ public class CSVProcess implements Processor { | ||||
|             result+=pack; | ||||
|         } | ||||
|  | ||||
|         ArrayList<Integer> tmp = new ArrayList<>(); | ||||
|         tmp.get(0); | ||||
|  | ||||
|         exchange.getIn().setBody(result); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -5,12 +5,19 @@ import generated.Package; | ||||
| import org.apache.camel.Exchange; | ||||
| import org.apache.camel.Processor; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| public class ValidatorProcess implements Processor { | ||||
|     @Override | ||||
|     public void process(Exchange exchange) throws Exception { | ||||
|  | ||||
|         //ArrayList<Integer> tmp = new ArrayList<>(); | ||||
|         //System.out.println(tmp.get(0)); | ||||
|  | ||||
|  | ||||
|  | ||||
|         MaterialType material = exchange.getIn().getBody(MaterialType.class); | ||||
|         Pattern pattern = Pattern.compile("\\d\\dx\\d\\dx\\d\\d"); | ||||
|         for (Package p: material.getPackages()) { | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user