Blueprint、Apache Camel和cxfrs
我正在尝试使用blueprint、ApacheCamel和ApacheCXFRS开发一个rest服务,其中服务实现将由camel处理 问题是rest端点似乎没有分配给camel 这是我得到的例外: 启动Camel时出错:CamelContext(blueprintContext) 由于存在已在/crm上运行的终结点 我的蓝图如下:Blueprint、Apache Camel和cxfrs,cxf,apache-camel,jbossfuse,blueprint-osgi,cxfrs,Cxf,Apache Camel,Jbossfuse,Blueprint Osgi,Cxfrs,我正在尝试使用blueprint、ApacheCamel和ApacheCXFRS开发一个rest服务,其中服务实现将由camel处理 问题是rest端点似乎没有分配给camel 这是我得到的例外: 启动Camel时出错:CamelContext(blueprintContext) 由于存在已在/crm上运行的终结点 我的蓝图如下: <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<jaxrs:server id="customerService" address="/crm" staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref component-id="customerSvc"/>
</jaxrs:serviceBeans>
<jaxrs:features>
<bean class="io.fabric8.cxf.endpoint.SwaggerFeature"/>
<bean class="io.fabric8.cxf.endpoint.ManagedApiFeature"/>
</jaxrs:features>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="customerSvc" class="restfuse.CustomerService"/>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<route customId="true" id="timerToLog">
<from uri="cxfrs:bean:customerService"/>
<setBody>
<method ref="helloBean" method="hello"></method>
</setBody>
<log message="The message contains ${body}"/>
<to uri="mock:result"/>
</route>
关于使用blueprint的cxf rs web服务,我也遇到了同样的问题。对于我所看到的,如果您尝试将camel cxf组件与cxf定义混合使用,当camel上下文启动时,它会尝试两次创建相同的cxf enpoints,因此它以:启动camel期间出错:CamelContext(blueprintContext)结束,因为有一个端点已在运行 我设法解决了将
更改为
并修改jaxrs:servicebean pojo注入direct:start端点并将接收到的对象作为主体发送的问题
这是我的密码:
blueprint.xml
在此修复之后,上下文将毫无错误地启动并完美地工作。我希望这有帮助 使用CXFRsServer而不是jaxrs服务器也解决了这个问题。也许您已经有了另一个使用CXF的示例/应用程序,该示例/应用程序正在使用address/crm。尝试将ddress=“/crm”更改为其他内容,例如/crm2或其他内容Tanks Claus,是的,我确实更改了此内容,但没有帮助。
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/cxf/camel-cxf-blueprint.xsd
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">
<jaxrs:server id="rsAuthApiSvc"
address="http://localhost:9898/authservice"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref component-id="pmAuthService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="pmAuthService" class="com.platamovil.platamovil.auth.rs.PMAuthService"/>
<camelContext trace="false" streamCache="true" id="authApiContext" xmlns="http://camel.apache.org/schema/blueprint">
<route id="restApiRoute">
<from uri="direct:start"/>
<log message="received from WS: ${body}"/>
<setBody>
<constant>{"status":"OK"}</constant>
</setBody>
</route>
</camelContext>
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.camel.EndpointInject;
import org.apache.camel.ProducerTemplate;
import com.platamovil.platamovil.auth.api.PMAuthMessage;
public class PMAuthService {
@EndpointInject(uri="direct:start")
ProducerTemplate producer;
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/authenticateclient")
public PMAuthMessage processAuthService(PMAuthMessage in_msg) throws Exception{
System.out.println("message arrived");
return producer.requestBody(in_msg).toString()
}
}