• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Consume类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.camel.Consume的典型用法代码示例。如果您正苦于以下问题:Java Consume类的具体用法?Java Consume怎么用?Java Consume使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Consume类属于org.apache.camel包,在下文中一共展示了Consume类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:RoutePojo.java


示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:CdiCamelExtension.java


示例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");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:MyBean.java


示例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));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CdiCamelExtension.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:AnnotatedConsumeImpl.java


示例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"};
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:DistributeRecordsBean.java


示例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());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CamelPostProcessorHelper.java


示例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");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JmsRequestReplyManualReplyTest.java


示例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");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:JmsRequestReplyManualWithJMSReplyToTest.java


示例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"};
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MyCamel2RecipientList.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MyConsumer.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MyCamel1Consumer.java


示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MyCamel2Consumer.java


示例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)));
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:34,代码来源:CdiCamelExtension.java


示例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);
}
 
开发者ID:statefulj,项目名称:statefulj,代码行数:14,代码来源:CamelBinder.java


示例16: routeMe

import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "direct:start")
@RoutingSlip(delimiter = ",")
public List<String> routeMe(String body, @Headers Map<String, Object> headers) {
    ArrayList<String> results = new ArrayList<String>();

    Object slip = headers.get("myRoutingSlipHeader");
    if (slip != null) {
        String[] uris = slip.toString().split(",");
        Collections.addAll(results, uris);
    }

    results.add("mock:oneMore");

    return results;
}
 
开发者ID:CamelCookbook,项目名称:camel-cookbook-examples,代码行数:16,代码来源:RoutingSlipAnnotated.java


示例17: routeMe

import org.apache.camel.Consume; //导入依赖的package包/类
/**
 * Returns the next endpoint to route a message to or null to finish routing.
 * This implementation leverages Camel's
 * <a href="http://camel.apache.org/bean-integration.html">Bean injection</a>
 * to pass parts of the Camel Exchange to the method for processing. This can
 * help the code be easier to maintain as it does not need the extra boilerplate
 * code for extracting the relative data from the Exchange.
 * <p></p>
 * This implementation stores an int property with the message exchange that is
 * used to drive the routing behavior. This method will be called from multiple
 * threads, one per message, so storing message specific state as a property is
 * a good strategy.
 *
 * @param body       the IN message converted to a String using Camel Bean injection
 * @param properties the properties map associated with the Camel Exchange
 * @return next endpoint uri(s) to route to or <tt>null</tt> to finish routing
 */
@Consume(uri = "direct:start")
@DynamicRouter(delimiter = ",")
public String routeMe(String body, @ExchangeProperties Map<String, Object> properties) {
    LOG.info("Exchange.SLIP_ENDPOINT = {}, invoked = {}",
        properties.get(Exchange.SLIP_ENDPOINT), properties.get(PROPERTY_NAME_INVOKED));

    // Store a property with the message exchange that will drive the routing
    // decisions of this Dynamic Router implementation.
    int invoked = 0;
    Object current = properties.get(PROPERTY_NAME_INVOKED); // property will be null on first call
    if (current != null) {
        invoked = Integer.valueOf(current.toString());
    }
    invoked++;
    properties.put(PROPERTY_NAME_INVOKED, invoked);

    if (invoked == 1) {
        return "mock:a";
    } else if (invoked == 2) {
        return "mock:b,mock:c";
    } else if (invoked == 3) {
        return "direct:other";
    } else if (invoked == 4) {
        return "mock:result";
    }

    // no more, so return null
    return null;
}
 
开发者ID:CamelCookbook,项目名称:camel-cookbook-examples,代码行数:47,代码来源:DynamicRouterAnnotated.java


示例18: send

import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "jms:queue:send")
public void send(@Body byte[] vo, @Header("concentratorId") String id) {
	
	Channel session = concentratorOnLine.getIoSession(id);
	if(session == null){
		System.out.println("集中器会话中断,无法发送");
		return;
	}
	session.write(vo);
	
}
 
开发者ID:xcjava,项目名称:ymesb,代码行数:12,代码来源:SendMsgConsume.java


示例19: doManagerExecute

import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "jms:queue:com.ymsino.esb.domain?concurrentConsumers=1&maxConcurrentConsumers=30")
public Serializable doManagerExecute(@Body Object vo, @Header("method") String method, @Header("beanName") String beanName) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
	if(!beanName.endsWith("Manager"))
		return null;
	
	Object invokeBean = applicationContext.getBean(beanName);
   	Method[] allMethods = invokeBean.getClass().getMethods();
   	for(Method itemMethod : allMethods){
   		if(itemMethod.getName().equals(method)){
   			Serializable resultObj = (Serializable) itemMethod.invoke(invokeBean, vo);
   	    	return resultObj;
   		}
   	}
   	return null;
}
 
开发者ID:xcjava,项目名称:ymesb,代码行数:16,代码来源:DomainConsume.java


示例20: onFileSendToQueue

import org.apache.camel.Consume; //导入依赖的package包/类
@Consume(uri = "file:src/data?noop=true")
public void onFileSendToQueue(String body, @Header("CamelFileName") String name) {
    LOG.info("Incoming file: {}", name);
    producer.sendBody(body);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:SendFileRecordsToQueueBean.java



注:本文中的org.apache.camel.Consume类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Object3D类代码示例发布时间:2022-05-22
下一篇:
Java ThemeChangeInterceptor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap