我已经从我的spring.xml文件和我正在获得的堆栈跟踪中发布了一段摘录.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:util="http://www.springframework.org/schema/util" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.0.0.xsd"
default-init-method="init" default-lazy-init="false">
<!-- import web service configuration -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<package>com.testdomain.testpackage</package>
</camelContext>
...
</beans>
Run Code Online (Sandbox Code Playgroud)
这引发了这个异常:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://camel.apache.org/schema/spring]
Offending resource: class path resource [spring-config.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) …Run Code Online (Sandbox Code Playgroud) 必须在我用XML定义的camel路由中抛出异常.发现throwException声明可从Camel 2.3获得,如下所示:
<throwException ref="forced"></throwException>
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何定义forced要抛出的异常类.由于可以使用不同的异常消息多次抛出相同的异常 - 最好知道是否throwException具有其他形式的定义,以便就地定义异常类和异常消息.
我正在使用Camel&Spring开发Java项目.我们想在Spring完成它的事情并且Camel完成构建所有路由之后在单例bean上触发初始化方法.
我们不能在类创建时调用该方法,因为它与从@Component spring注释中获取的其他类具有动态链接,并且我们不知道这些类何时/是否已经加载到实际运行init方法作为a的一部分构造函数.
如何在Camel启动完成后立即调用一个或多个方法来运行?
谢谢!
维基百科定义XMPP为:
...基于XML的面向消息的中间件的开放标准通信协议.
xmpp.org定义XMPP为:
可扩展消息传递和在线协议(XMPP)是一种用于实时通信的开放式XML技术,可为各种应用提供支持.
虽然我确信这些定义都非常准确,但它们并没有告诉我一个关于我 - 一个Java开发人员 - 实际上可以用XMPP 做什么的事情!
例如,我听说XMPP可以用于面向消息的中间(MOM).怎么会这样?XMPP可以以某种方式与我的Apache Camel路由,我的ESB或某些SOA实现集成,以提供更好/更快/更强大的业务层吗?如果是这样,怎么样?!?!
一个很好的,英语 - 英语对XMPP的解释,以及一些实际的例子(更好的以MOM为中心)将不胜感激.提前致谢!
我现在开始与骆驼.我见过http客户端的http4组件和http服务器的jetty组件.
我见过几个使用其中一个的例子.我想知道是否可以将它们组合在一起.
例
from("jetty:http://0.0.0.0:8080/myapp/myservice")
.to("http4://www.google.com");
Run Code Online (Sandbox Code Playgroud)
这将使骆驼成为一个简单的基于http的路由器/代理.Web浏览器会点击骆驼网址而不是google.(谷歌只是一个例子,我有一个真正的基于POST的服务,我想使用)
这条路线可行吗?我应该研究Camel还是我需要一个不同的软件框架?将来我还需要在两者之间添加转换/过滤器.
我试过它并获得了一个nullpointer异常
[qtp757856402-14] SendProcessor DEBUG >>>> Endpoint[http4://www.google.com] Exchange[Message: [Body is instance of java.io.InputStream]]
[qtp757856402-14] DefaultErrorHandler DEBUG Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. On delivery attempt: 0 caught: java.lang.NullPointerException
[qtp757856402-14] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud) 这两者有何不同?
from(endpoint).to(endpoint:a, endpoint:b)
from(endpoint).multicast().to(endpoint:a, endpoint:b)
Run Code Online (Sandbox Code Playgroud)
找不到第一个的任何文档
首先,是的,我已经搜索了,是的,我已经阅读了每个人指向的相同的Apache文档.:-)我认为有一些混乱,我想我知道答案,所以让我列举一个我认为正确的例子,按照我认为的答案来做.谢谢.哦,我知道有些endChoice()行并不是绝对必要的,Camel会想出来,但我喜欢干净地描述的块,除非有一些理由不使用它们.
.choice()
.when(X1)
// do stuff
.choice()
.when(Y)
//do more stuff
.endChoice() // close inner when block
.end() // close inner choice block
.endChoice() // close first outer when
.when(X2)
// do other stuff
.endChoice() // close second outer when
.end() // close outer choice
Run Code Online (Sandbox Code Playgroud)
所以,我原来看看API,我认为end()用于关闭诸如choice和split之类的东西,而endChoice()用于关闭选择选项,比如when和otherwise.它看起来更像后者实际上是一个返回ChoiceDefinition的end().这使得这个名字好一点.
但是,如果我取出标有'close inner choice block'的end(),这意味着我继续下一行,即endChoice().这会关闭内部选择块吗?鉴于此,when(X2)仍然在when(X1)块内.所以,我认为我需要用endChoice()替换end()而不是删除它.所以结果如下:
.choice()
.when(X1)
// do stuff
.choice()
.when(Y)
//do more stuff
.endChoice() // close inner when block
.endChoice() // close inner choice block
.endChoice() // close first outer when
.when(X2)
// …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Jackson在Camel路由上与JSON序列化和反序列化POJO.其中一些有Java 8 LocalDate字段,我希望它们被序列化为YYYY-MM-DD字符串,而不是整数数组.
我们只对我们的Spring Boot应用程序使用Java配置,因此没有XML Camel配置.
我已经成功创建了一个ObjectMapper,它可以完成我想要的工作,我们系统的其他部分正在使用它来添加到我们的依赖项:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这对我们的应用程序配置:
@Bean
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
return builder
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
}
Run Code Online (Sandbox Code Playgroud)
示例传出REST路由:
@Component
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("servlet").contextPath("/mycontext")
.port(8080).bindingMode(RestBindingMode.json);
rest("/myendpoint)
.get()
.route()
.to("bean:myService?method=myMethod()");
}
}
Run Code Online (Sandbox Code Playgroud)
传入消息路由示例:
@Component
public class MyRouteBuilder extends RouteBuilder {
@Autowired
private MyBean myBean;
@Override
public void configure() {
from(uri)
.unmarshal().json(JsonLibrary.Jackson)
.bean(myBean);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,默认情况下,Camel会创建自己的ObjectMapper实例,因此不会选择Jackson2ObjectMapperBuilder自动添加的JSR310序列化程序/反序列化程序或禁用的WRITE_DATES_AS_TIMESTAMPS功能.我已经阅读了Camel JSON文档,但它没有说明如何使用Spring配置添加自定义DataFormat,或者如何为所有类型应用全局自定义.
那么如何使用Spring Boot Java配置告诉Camel使用我的ObjectMapper?
我想开发一个轮询包含CSV文件的目录的路由,并且对于每个文件,它使用Bindy解组每一行并在activemq中对其进行排队.
问题是文件可能非常大(一百万行)所以我更喜欢一次排队一行,但我得到的是Bindy末尾的java.util.ArrayList中的所有行记忆问题.
到目前为止,我有一点测试和解组工作,所以使用注释的Bindy配置是可以的.
这是路线:
from("file://data/inbox?noop=true&maxMessagesPerPoll=1&delay=5000")
.unmarshal()
.bindy(BindyType.Csv, "com.ess.myapp.core")
.to("jms:rawTraffic");
Run Code Online (Sandbox Code Playgroud)
环境是:Eclipse Indigo,Maven 3.0.3,Camel 2.8.0
谢谢
该DirectComponent文档给出了下面的例子:
from("activemq:queue:order.in")
.to("bean:orderServer?method=validate")
.to("direct:processOrder");
from("direct:processOrder")
.to("bean:orderService?method=process")
.to("activemq:queue:order.out");
Run Code Online (Sandbox Code Playgroud)
这和下面有什么区别吗?
from("activemq:queue:order.in")
.to("bean:orderServer?method=validate")
.to("bean:orderService?method=process")
.to("activemq:queue:order.out");
Run Code Online (Sandbox Code Playgroud)
我试图找到关于to()方法在Java DSL上的行为的文档,但是除了RouteDefinition javadoc之外(它给出了非常简单的"将交换发送到给定的端点")我发现空白:(