- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Exchange.property 上设置属性 isEven,然后使用选择 何时 在路由中评估它。
正在设置该属性,但无论 isEven 设置成什么,我总是得到otherwise 结果 (NACK)。
这里是我设置的地方:
// Below is used for development
// If the property.isEven == true then an ACK will be returned from the Mock HRM
// If false then NACK
int lastDigit = Integer.parseInt(exchange.getExchangeId().substring(exchange.getExchangeId().length() - 1));
// check if lastDigit is odd or even
if ((lastDigit & 1) == 0)
{
exchange.setProperty("isEven", Boolean.TRUE);
System.out.println("\n\n\n********** Exchange Id lastDigit " + lastDigit + " isEven: " + exchange.getProperty("isEven") + " ***********");
}
else
{
exchange.setProperty("isEven", Boolean.FALSE);
System.out.println("\n\n\n********** Exchange Id lastDigit " + lastDigit + " isEven: " + exchange.getProperty("isEven") + " ***********");
}
我正在设置的 println 显示甚至是我期望的方式。这是路线:
<!-- Used to ramdomly send Ack or Nack -->
<log message="isEven property is :: ${property[isEven]}" />
<camel:choice>
<camel:when>
<simple>"${property[isEven]}"</simple>
<transform>
<constant>ACK</constant>
</transform>
</camel:when>
<camel:otherwise>
<transform>
<constant>NACK</constant>
</transform>
</camel:otherwise>
</camel:choice>
日志消息从不计算表达式 ${property[isEven]}这是输出 log[isEven 属性是::${property[isEven]}]
如果我更改简单表达式以显式检查是否为真,无论属性设置为什么,我总是会收到 ACK。
<simple>"${property[isEven]} == true"</simple>
我在网上搜索过,但找不到很多使用 simple 和 Exchange 属性的示例。
谁能看到我错过了什么?
谢谢,
安德鲁
在 Peter 展示他可以轻松做到之后,我尝试了他的两个我之前没有尝试过的例子。这是一个。它对我不起作用。无论 isEven 是真还是假,它都会生成 Hello::NACK:
<camel:choice>
<camel:when>
<simple>${property[isEven]} == "true"</simple>
<log message="HELLO :: ACK" />
<!-- <transform>
<constant>ACK</constant>
</transform> -->
</camel:when>
<camel:otherwise>
<log message="HELLO :: NACK" />
<!-- <transform>
<constant>NACK</constant>
</transform> -->
</camel:otherwise>
</camel:choice>
这里有一些有趣的事情。它看起来像下面的日志说它是空的在最后一个像
********** Exchange Id lastDigit 2 isEven: true ***********
14/02/20 14:09:13 INFO interceptor.Tracer: >>> (toHRMRoute) bean://hl7handler?method=handleORM --> log[isEven property is :: ${property[isEven]}] <<< Pattern:InOut, Properties {CamelToEndpoint=bean://hl7handler?method=handleORM, CamelMessageHistory [DefaultMessageHistory[routeId=toHRMRoute, node=to3], DefaultMessage History[routeId=toHRMRoute, node=log1]], CamelCreatedTimestamp=Thu Feb 20 14:09:13 CST 2014}
14/02/20 14:09:13 INFO toHRMRoute: ** isEven property is :: **
我认为 Peter 是正确的,因为它必须是我设置路线的方式。
<endpoint id="hrmMockHL7Listener"
uri="netty:tcp://localhost:9200?sync=true" />
<!-- Sending data using postman to a rest server-->
<route id="pushRESTRoute">
<from uri="cxfrs://bean://pushRESTServer" />
<!-- this process is where we set isEven on the Exchange-->
<process ref="transformer"/>
<!-- Send it to a tcp listener at port 9200-->
<to ref="hrmMockHL7Listener" />
</route>
<!-- Changed routes does the Exchange keep properties? -->
<route id="toMRoute">
<from uri="hrmMockHL7Listener" />
<to uri="bean:hl7handler?method=handleORM" />
<!-- Used to ramdomly send Ack or Nack -->
<log message="isEven property is :: ${property[isEven]}">
// see the beginning of the question for choice code.
查看输出,似乎 isEven 属性在路由之间被丢弃:
14/02/21 09:37:26 INFO interceptor.Tracer: >>> (pushRESTRoute) ref:transformer --> tcp://localhost:9200 <<< Pattern:InOut, Properties {CamelMessageHistory=[DefaultMessageHistory[routeId=pushRESTRoute, node=process1], DefaultMessageHistory[routeId=pushRESTRoute, node=to1]], CamelCreatedTimestamp=Fri Feb 21 09:37:26 CST 2014, isEven=true}
最后看到 isEven 了吗?下一个来的示踪剂没有它
/02/21 09:37:26 INFO interceptor.Tracer: >>> (toMRoute) from(tcp://localhost:9200) --> bean://hl7handler?method=handleORM <<< Pattern:InOut, Properties:{CamellMessageHistory=[DefaultMessageHistory[routeId=toMRoute, node=to3]], CamelCreatedTimestamp=Fri Feb 21 09:37:26 CST 2014}
来自 Exchange javadoc
An Exchange is the message container holding the information during the entire routing of a Message received by a Consumer.
是否完整包括跨不同的路线?
最佳答案
为了测试我稍微改变了路线:
<route id="startRoute">
<from uri="direct:start" />
<multicast stopOnException="true">
<to uri="direct:trigger" />
<to uri="direct:trigger" />
<to uri="direct:trigger" />
</multicast>
</route>
<route>
<from uri="direct:trigger" />
<process ref="myProcessor" />
<log message="isEven property is :: ${property[isEven]}" />
<camel:choice>
<camel:when>
<simple>"${property.isEven}"</simple>
<log message="HELLO :: ACK" />
</camel:when>
<camel:otherwise>
<log message="HELLO :: NACK" />
</camel:otherwise>
</camel:choice>
</route>
<!-- scope singleton is default -->
<bean id="myProcessor" class="ch.keller.test.testcamelspring.util.Trigger" scope="singleton" />
处理器定义如下:
public class Trigger implements Processor {
@Override
public void process(final Exchange exchange) throws Exception {
// your code comes here
}
}
对我来说,以下表达式按预期工作:
<simple>"${property[isEven]}"</simple>
或
<simple>${property[isEven]}</simple>
或
<simple>${property[isEven]} == "true"</simple>
或
<simple>"${property.isEven}"</simple>
或
<simple>${property.isEven} == "true"</simple>
或
<simple>${property.isEven}</simple>
我更喜欢最后一个版本。
编辑:
如果属性设置正确,为了调试,启用showProperties
在你的 Spring 配置文件中:
<bean id="traceFormatter" class="org.apache.camel.processor.interceptor.DefaultTraceFormatter">
<property name="showBreadCrumb" value="false" />
<property name="showProperties" value="true" />
</bean>
然后您应该在日志中看到以下输出(缩短以提高可读性):
[main] Tracer INFO >>> (route1) log[isEven property is :: ${property[isEven]}] --> choice <<< Pattern:InOnly, Properties:{CamelToEndpoint=direct://trigger, ..., isEven=true, ...
重要的部分是isEven=true
.
编辑:
当转发到另一条路由时,该属性被保留,可以证明如下:
<route>
<from uri="direct:trigger" />
<process ref="myProcessor" />
<log message="isEven property is :: ${property[isEven]}" />
<to uri="direct:acktarget" />
</route>
<route>
<from uri="direct:acktarget" />
<log message="acktarget: isEven property is :: ${property[isEven]}" />
</route>
输出:
exchange.getExchangeId() = ID-pis-iMac-local-54434-1393006139076-0-3
********** Exchange Id lastDigit 3 isEven: false ***********
[ main] route1 INFO isEven property is :: false
[ main] route2 INFO acktarget: isEven property is :: false
exchange.getExchangeId() = ID-pis-iMac-local-54434-1393006139076-0-4
********** Exchange Id lastDigit 4 isEven: true ***********
[ main] route1 INFO isEven property is :: true
[ main] route2 INFO acktarget: isEven property is :: true
exchange.getExchangeId() = ID-pis-iMac-local-54434-1393006139076-0-5
********** Exchange Id lastDigit 5 isEven: false ***********
[ main] route1 INFO isEven property is :: false
[ main] route2 INFO acktarget: isEven property is :: false
即使我在将消息转发到其他路由之前调用一个 bean,该属性也会保留。所以,我猜你的问题在 <to uri="bean:hl7handler?method=handleORM" />
.在调用此 bean 之前尝试记录该属性并查看该属性是否仍然设置。如果没有,请查看 bean。
关于properties - Camel Exchange 属性不使用 xml 中的简单进行评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21911816/
有没有办法使用 EWS Managed API 搜索 Exchange 以查找所有文件夹中的所有电子邮件。我正在使用 FindItems API 调用——但这似乎要求将搜索限制在单个文件夹中。
我已经看到这个问题被问了好几次,但到目前为止,答案都非常机械化和令人失望: EWS 与 EAS 有什么区别? 现在,大多数网站都给出以下内容:“一个是移动设备协议(protocol),另一个是 Web
我们将 Exchange 集成到我们的 CRM(日记和电子邮件)中;我们通过 SQL 2008 服务器中的 CRL 函数完成了这项工作,这些函数处理所有身份验证以及与 Exchange 2007 We
我想为交换服务器创建插件。 Exchange 服务器是否为此提供任何 SDK。如果有人知道,请告诉我。 最佳答案 此链接应为您提供可用内容的概览。 https://msdn.microsoft.com
我刚开始使用EWS(Exchange Web服务),并且正在寻找一个简单的示例,该示例演示如何发送带有附件的电子邮件。我搜索了一个示例,但找不到简单明了的示例。我找到了有关如何发送电子邮件但不发送带有
我在一个客户站点工作,并通过网络邮件连接到他们的 Exchange 2000 服务器。我正在运行 Outlook 2007,并通过 HTTP 连接到我的公司 Exchange 2007。 是否有任何方
从 Exchange 2007 开始,安装 Exchange 时不再安装 MAPI。在这些系统上 this install如果您想使用 MAPI,则除 Exchange 外还需要。 我的软件依赖于 E
交换 2010。 我已经阅读了有关 Exchange 中的通知订阅、邮箱事件和 EWS 的信息,据我所知,通知客户端应用程序必须始终与 EWS 保持连接。我对吗? 我的任务看起来很简单 - 当消息到达
我试图弄清楚节流政策如何影响 EWS。 对于 EWS,我们有以下值: EWSMaxSubscription:模拟用户完成的事件订阅数。 EWSMaxConcurrency:单个客户端可能执行的并发连接
我在 Exchange 2010 SP2 服务器上使用 EWS 我似乎找不到任何命令/文档来检索交换服务器中所有用户(邮箱/别名)的完整列表 这个问题已经问了好几次了,但我还没有看到任何答案 谢谢 最
我正在使用 CalendarItemType View 来检索日历项目。我唯一关心的项目是我创建的项目,我知道它们都是每周重复出现的项目。我能够获取每个单独的事件,并从其中任何一个中获取重复出现的主项
我从 Exchange 2007 服务器的地址开始: user@domain.exchangeserver.org 我尝试发送自动发现请求,如 MSDN 中所述. 我尝试使用 TechNet Whit
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 12 年前。 Improve thi
这是我所拥有的... 我有一个跟踪条形码类型标签的程序。我可以在数据库中选择一个项目并为它打印一个标签。我正在添加向我们的 Exchange 服务器 (2007 SP1) 上的特定收件箱发送电子邮件并
我的公司正在开发一个桌面和移动电子邮件客户端的项目,该客户端可以连接到不同的邮件服务器,用户或服务器管理员只需进行最少的配置。我们希望能够支持 Exchange,但经过一些研究后我意识到有许多问题需要
我正在尝试调用 GetUserAvailabilityRequest 来自不遵守夏令时的南非标准时间,但是,TimeZone 元素需要 StandardTime 和 DaylightTime 子元素,
我想在我的交换服务器上收到电子邮件时运行脚本。我真的没有关于如何实现这一点的好方向。我已经用 VB 编写了脚本并在 outlook 上对其进行了测试。我错误地认为您可以像在 Outlook 中一样从
我在使用 Exchange 2010 Web 服务 (EWS) 创建全天事件约会时遇到了麻烦。 根据现有要求,创建全天事件约会对象需要指定开始和结束时间(即 10/20/2011 12:00:00 A
是否有任何公共(public) Exchange 服务器(模拟器)可用于测试/试验我的 Exchange Web 服务实现? 最佳答案 我怀疑没有免费的东西。创建自己的 VM 会容易得多。您将需要具有
我正在尝试使用最新的 Exchange Web 服务 DLL,但是当我搜索我的硬盘时,我看到了许多版本的 Microsoft.Exchange.WebServices.DLL,最新的是版本 14.0.
我是一名优秀的程序员,十分优秀!