【发布时间】:2017-05-04 05:40:02
【问题描述】:
我不得不询问骆驼路线的行为,这是愚蠢(但易于理解)的逻辑描述。 在主题中 - 我需要将信息从一条路线的交换标头推送到另一条路线。 都是关于CMDB系统和监控工具zabbix的。 好吧,首先我有一个可以在 CMDB 中切换 CI 状态的路由:
<route>
<description> route catching CI ID in jms queue, check it on exist and switch CI state to incident
</description>
<from uri="jms:switchCIStateQueue"/>
<filter>
<simple>${body} regex '[\d]+'</simple>
<to uri="bean:otrsCIApi?method=getCIBodyByID(${body})"/>
<filter>
<simple>${body} regex '\{.+?\}'</simple>
<marshal>
<json library="Jackson"/>
</marshal>
<unmarshal>
<json library="Jackson" unmarshalTypeName="ts.team.otrs.ci.OtrsCI"/>
</unmarshal>
<to uri="bean:otrsCIApi?method=switchOTRSCIState(${body})"/>
</filter>
</filter>
</route>
它运行良好,但我必须从另一条路线使用此操作,该路线有许多检查、过滤器和选择。 我的问题是我没有 CI ID 作为主体(但将其保留在标题中)在主要逻辑路线的深度。
<route>
<description>Route catch triggerid
and creates a ticket in OTRS, link it to host
</description>
<from uri="direct:zab_trig_2_otrs_tick"/>
<to uri="bean:zabbixApi?method=getTriggerByID(body)"/>
<filter>
<simple>${body} regex '\{.+?\}'</simple>
<marshal>
<json library="Jackson"/>
</marshal>
<unmarshal>
<json library="Jackson" unmarshalTypeName="ts.team.zabbix.trigger.SingleTrigger"/>
</unmarshal>
<setHeader headerName="ZabbixTrigger" id="_setZabbixTrigger">
<simple>${body}</simple>
</setHeader>
<!-- search CI in OTRS -->
<to uri="bean:otrsCIApi?method=searchCI(${body.getHosts().get(0).getName()})"/>
<!-- Array of CI ID like [] or ["1"] -->
<split streaming="true">
<simple>${body}</simple>
<!-- place it in header-->
<setHeader headerName="HostID">
<simple>${body}</simple>
</setHeader>
<to uri="bean:otrsLinkApi?method=ListLinkedTicketsTitleFiltered(${body},${header.ZabbixTrigger.getDescription()})"/>
<!-- return JSONArray with State=open otrs Tickets ID -->
<choice>
<when id="ticketslist_empty">
<simple>${body} == ''</simple>
<!-- Create ticket, connect it to host in OTRS -->
<to uri="bean:otrsTicketApi?method=createNewTicket(${header.ZabbixTrigger.getDescription()},${header.ZabbixTrigger.getPriority()})"/>
<!-- return body body with ticket id, create link with ${header.HostID} -->
<to uri="bean:otrsLinkApi?method=LinkAdd(${header.HostID},${body})"/>
<!-- Here i need to switch CI state if incident priority is higher than 3(Normal)-->
<when>
<simple>${header.ZabbixTrigger.getPriority()} > 3</simple>
<!-- here i need to send ${header.HostID} to previous described route (jms:switchCIStateQueue)-->
</when>
</when>
</choice>
</split>
</filter>
</route>
所以,这条路线有一段:
<when>
<simple>${header.ZabbixTrigger.getPriority()} > 3</simple>
<!-- here i need to send ${header.HostID} to previous described route (jms:switchCIStateQueue)-->
</when>
我需要将一些信息从我的标头发送到 jms:switchCIStateQueue (或直接路由,无论到哪里)。 我希望,我对问题的描述非常完整和简单。
【问题讨论】:
-
很遗憾没有:) 有什么问题吗?是什么阻止您将 ${header.HostID} 放入 ${body} 中,因为“先前描述的路线”期望它?反之亦然,您的 CID 不是来自 ${body},而是来自该路由中的标头?
-
@Vadim,感谢您的评论。我很抱歉在我的描述中如此粗鲁。主要问题是什么 - 我需要将 CIID 推入第一个描述的路线。我不能赶上,我怎么能做到我的大路线。导致需要的 CIID 放在标头 ${header.HostID} 而不是正文中。如何将 ${header.HostID} 放入正文?
-
我的意思是,我不知道将信息从 ${header.HostID} 放置到 jms:switchCIStateQueue 的正确方法。如果您有一些想法,我将不胜感激:)
标签: spring apache-camel integration