![JAR search and dependency download from the Maven repository](/logo.png)
info.kwarc.sally4.lmh.factories.Main Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mhw-base Show documentation
Show all versions of mhw-base Show documentation
Implements the interaction of assigning a MathHub document to a Worker.
The newest version!
package info.kwarc.sally4.lmh.factories;
import java.util.HashMap;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class Main extends RouteBuilder{
HashMap t = new HashMap();
public Processor setPriorities = new Processor() {
@Override
public void process(Exchange a) throws Exception {
String uid = a.getIn().getHeader("uid", String.class);
if (!t.containsKey(uid))
t.put(uid, -1);
int cnt = t.get(uid);
t.put(uid, cnt+1);
int prio = cnt;
System.out.println("uid="+uid+" body="+a.getIn().getBody(String.class)+ " " + prio);
a.getIn().setHeader("prio", prio);
a.getIn().setHeader("JMSProperty", Math.max(0, 4-cnt/10));
}
};
public Processor resetPriorities = new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
t.clear();
}
};
public void configure() throws Exception {
from("direct:a")
.setHeader("uid", constant(1))
.inOut("activemq:queue:testqueue")
.to("log:result_a");
from("direct:b")
.setHeader("uid", constant(2))
.to("activemq:queue:testqueue")
.to("log:result_b");
from("activemq:queue:testqueue")
/* .process(setPriorities)
.resequence(header("prio"))
.batch().timeout(4000).size(100).allowDuplicates()
.process(resetPriorities)*/
.bean(method(this, "reply"));
};
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
Main main = new Main();
context.addRoutes(main);
context.start();
//for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy