本文整理汇总了Java中org.apache.camel.Consume类的典型用法代码示例。如果您正苦于以下问题:Java Consume类的具体用法?Java Consume怎么用?Java Consume使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Consume类属于org.apache.camel包,在下文中一共展示了Consume类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listen
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "activemq:queue:inbox?concurrentConsumers=10")
@RecipientList
public String listen(Exchange exchange) {
topic.send(exchange);
String type = exchange.getIn().getHeader("type", String.class);
return "direct:" + type;
}
示例2: shouldDeployDefaultCamelContext
import org.apache.camel.Consume; //导入依赖的package包/类
private boolean shouldDeployDefaultCamelContext(Set<Bean<?>> beans) {
return beans.stream()
// Is there a Camel bean with the @Default qualifier?
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.filter(hasType(CamelContextAware.class).or(hasType(Component.class))
.or(hasType(RouteContainer.class).or(hasType(RoutesBuilder.class))))
.map(Bean::getQualifiers)
.flatMap(Set::stream)
.filter(isEqual(DEFAULT))
.findAny()
.isPresent()
// Or a bean with Camel annotations?
|| concat(camelBeans.stream().map(AnnotatedType::getFields),
camelBeans.stream().map(AnnotatedType::getMethods))
.flatMap(Set::stream)
.map(Annotated::getAnnotations)
.flatMap(Set::stream)
.filter(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
.or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
.or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
.or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
.or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
.findAny()
.isPresent()
// Or an injection point for Camel primitives?
|| beans.stream()
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.map(Bean::getInjectionPoints)
.flatMap(Set::stream)
.filter(ip -> getRawType(ip.getType()).getName().startsWith("org.apache.camel"))
.map(InjectionPoint::getQualifiers)
.flatMap(Set::stream)
.filter(isAnnotationType(Uri.class).or(isAnnotationType(Mock.class)).or(isEqual(DEFAULT)))
.findAny()
.isPresent();
}
示例3: myMethod
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "activemq:Test.BindingQueue")
public void myMethod(@Headers Map<?, ?> headers, String body) {
this.headers = headers;
this.body = body;
// now lets notify we've completed
producer.sendBody("Completed");
}
示例4: processAnnotatedType
import org.apache.camel.Consume; //导入依赖的package包/类
private void processAnnotatedType(@Observes ProcessAnnotatedType<?> pat) {
if (pat.getAnnotatedType().isAnnotationPresent(Vetoed.class)) {
pat.veto();
}
if (hasAnnotation(pat.getAnnotatedType(), Converter.class)) {
converters.add(pat.getAnnotatedType().getJavaClass());
}
if (hasAnnotation(pat.getAnnotatedType(), BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class)) {
camelBeans.add(pat.getAnnotatedType());
}
if (hasAnnotation(pat.getAnnotatedType(), Consume.class)) {
eagerBeans.add(pat.getAnnotatedType());
}
if (hasAnnotation(pat.getAnnotatedType(), ImportResource.class)) {
resources.add(pat.getAnnotatedType().getAnnotation(ImportResource.class));
}
}
示例5: handleTitle
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "seda:book")
public void handleTitle(String title) {
Transactional tx = this.getClass().getAnnotation(Transactional.class);
if (tx == null) {
throw new IllegalStateException("Spring annotation-driven should have instrumented this class as @Transactional");
}
if (!"NEVER".equals(tx.propagation().name())) {
throw new IllegalStateException("Should be NEVER propagation");
}
if (!tx.readOnly()) {
throw new IllegalStateException("Should be read only");
}
if (!title.contains("in Action")) {
throw new IllegalArgumentException("Not a book title we like");
}
producer.sendBody(title);
}
示例6: route
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "activemq:personnel.records")
@RecipientList
public String[] route(@XPath("/person/city/text()") String city) {
if (city.equals("London")) {
LOG.info("Person is from EMEA region");
return new String[] {"file:target/messages/emea/hr_pickup",
"file:target/messages/emea/finance_pickup"};
} else {
LOG.info("Person is from AMER region");
return new String[] {"file:target/messages/amer/hr_pickup",
"file:target/messages/amer/finance_pickup"};
}
}
示例7: consumerInjection
import org.apache.camel.Consume; //导入依赖的package包/类
public void consumerInjection(Method method, Object bean, String beanName) {
Consume consume = method.getAnnotation(Consume.class);
if (consume != null && matchContext(consume.context())) {
LOG.debug("Creating a consumer for: " + consume);
subscribeMethod(method, bean, beanName, consume.uri(), consume.ref(), consume.property());
}
}
示例8: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "activemq:queue:foo")
public void doSomething(@Header("JMSReplyTo") Destination jmsReplyTo, @Body String body) throws Exception {
assertEquals("Hello World", body);
String endpointName = "activemq:" + jmsReplyTo.toString();
endpointName = endpointName.replaceAll("//", ":");
tempName = endpointName;
latch.countDown();
template.sendBody(tempName, "Bye World");
}
示例9: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "activemq:queue:foo")
public void doSomething(@Header("JMSReplyTo") Destination jmsReplyTo, @Body String body) throws Exception {
assertEquals("Hello World", body);
String endpointName = "activemq:" + jmsReplyTo.toString();
template.sendBody(endpointName, "Bye World");
}
示例10: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "direct:foo", context = "camel-2")
@RecipientList(context = "camel-2")
public String[] doSomething(String body) {
LOG.info("Received body: " + body);
return new String[]{"mock:foo", "mock:result"};
}
示例11: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "direct:start")
public void doSomething(String body) {
ObjectHelper.notNull(destination, "destination");
LOG.info("Received body: " + body);
destination.sendBody(body);
}
示例12: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "direct:start", context = "camel-1")
public void doSomething(String body) {
ObjectHelper.notNull(destination, "destination");
LOG.info("Received body: " + body);
destination.sendBody(body);
}
示例13: doSomething
import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "direct:start", context = "camel-2")
public void doSomething(String body) {
ObjectHelper.notNull(destination, "destination");
LOG.info("Received body: " + body);
destination.sendBody(body);
}
示例14: shouldDeployDefaultCamelContext
import org.apache.camel.Consume; //导入依赖的package包/类
private boolean shouldDeployDefaultCamelContext(BeanManager manager, Set<SyntheticBean<?>> beans) {
// TODO: find a way to 'pre-filter' by refining the bean types passed to the bean manager
return concat(manager.getBeans(Object.class, ANY).stream(), beans.stream())
// Is there a Camel bean with the @Default qualifier?
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.filter(hasType(CamelContextAware.class).or(hasType(Component.class))
.or(hasType(RouteContainer.class).or(hasType(RoutesBuilder.class))))
.map(Bean::getQualifiers)
.flatMap(Set::stream)
.anyMatch(isEqual(DEFAULT))
// Or a bean with Camel annotations?
|| concat(camelBeans.stream().map(AnnotatedType::getFields),
camelBeans.stream().map(AnnotatedType::getMethods))
.flatMap(Set::stream)
.map(Annotated::getAnnotations)
.flatMap(Set::stream)
.anyMatch(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
.or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
.or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
.or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
.or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
// Or an injection point for Camel primitives?
|| concat(manager.getBeans(Object.class, ANY).stream(), beans.stream())
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.map(Bean::getInjectionPoints)
.flatMap(Set::stream)
.filter(ip -> getRawType(ip.getType()).getName().startsWith("org.apache.camel"))
.map(InjectionPoint::getQualifiers)
.flatMap(Set::stream)
.anyMatch(isAnnotationType(Uri.class).or(isEqual(DEFAULT)));
}
示例15: addConsumeAnnotation
import org.apache.camel.Consume; //导入依赖的package包/类
private void addConsumeAnnotation(CtMethod ctMethod, String uri) {
MethodInfo methodInfo = ctMethod.getMethodInfo();
ConstPool constPool = methodInfo.getConstPool();
Annotation consume = new Annotation(Consume.class.getName(), constPool);
StringMemberValue valueVal = new StringMemberValue(constPool);
valueVal.setValue(uri);
consume.addMemberValue("uri", valueVal);
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
attr.addAnnotation(consume);
methodInfo.addAttribute(attr);
}