我正在使用ESB在SQL和REST调用之间路由数据。到目前为止,这工作正常,但是当我想向REST调用中添加选项时。例如:
2018-12-24 16:15:39.795 CST [orderer/consensus/kafka] processMessagesToBlocks -> ERRO 0ec [channel: ordererchannel] Error during consumption: kafka: error while consuming ordererchannel/0: kafka: error decoding packet: CRC didn't match expected 0x0 got 0xe38a6876
2018-12-24 16:15:39.796 CST [orderer/consensus/kafka] processMessagesToBlocks -> WARN 0ed [channel: ordererchannel] Deliver sessions will be dropped if consumption errors continue.
2018-12-24 16:15:41.796 CST [orderer/consensus/kafka/sarama] dispatcher)-fm -> DEBU 0ee consumer/ordererchannel/0 finding new broker
2018-12-24 16:15:41.796 CST [orderer/consensus/kafka/sarama] RefreshMetadata -> DEBU 0ef client/metadata fetching metadata for [ordererchannel] from broker 192.168.1.36:9092
2018-12-24 16:15:41.809 CST [orderer/consensus/kafka/sarama] Open -> DEBU 0f0 ClientID is the default of 'sarama', you should consider setting it to something application-specific.
2018-12-24 16:15:41.809 CST [orderer/consensus/kafka/sarama] subscriptionConsumer -> DEBU 0f1 consumer/broker/3 added subscription to ordererchannel/0
2018-12-24 16:15:41.810 CST [orderer/consensus/kafka] processMessagesToBlocks -> WARN 0f2 [channel: ordererchannel] Consumption will resume.
2018-12-24 16:15:41.816 CST [orderer/consensus/kafka/sarama] withRecover -> DEBU 0f3 Connected to broker at 192.168.1.50:9092 (registered as #3)
2018-12-24 16:15:41.832 CST [orderer/consensus/kafka/sarama] subscriptionConsumer)-fm -> DEBU 0f4 consumer/broker/3 disconnecting due to error processing FetchRequest: kafka: error decoding packet: CRC didn't match expected 0x0 got 0xe38a6876
2018-12-24 16:15:41.833 CST [orderer/consensus/kafka/sarama] abort -> DEBU 0f5 Closed connection to broker 192.168.1.50:9092
,SQL代码为:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<propertyPlaceholder id="placeholder"
location="file:${karaf.home}/etc/nl.test.astron.sql.cfg" />
<restConfiguration bindingMode="json" component="servlet">
<endpointProperty key="servletName" value="ASTRONServlet" />
</restConfiguration>
<rest path="/get/astrondata">
<get uri="">
<to pattern="InOut" uri="direct:get" />
</get>
</rest>
<route id="get_to_uri">
<from uri="direct:get"/>
<setHeader headerName="boundRaMin">
<simple>70</simple>
</setHeader>
<setHeader headerName="boundRaMax">
<simple>90</simple>
</setHeader>
<setHeader headerName="boundDecMin">
<simple>0</simple>
</setHeader>
<setHeader headerName="boundDecMax">
<simple>30</simple>
</setHeader>
<to uri="sql:{{sql.getDatabase}}?
outputType=SelectList&
greedy=true&
useIterator=false"/>
</route>
正如在这里可以看到的那样,boundRaMin,boundRaMax,boundDecMin,boundDecMax都由标头设置,但是我想根据rest调用中定义的选项来设置这些变量。因此,例如以下调用:
应将正确的value1 ... value4值填充到标题中。这些查询参数似乎没有映射到标题。
答案 0 :(得分:1)
根据camel-sql组件,从Camel 2.14开始,您可以使用简单表达式。因此,尝试将占位符sql.getDatabase修改为以下内容:
sql.getDatabase=SELECT * FROM dbo.astron_data WHERE :${header.boundRaMin} < ra AND
ra < ${header.boundRaMax} AND ${header.boundDecMin} < dec AND dec < ${header.boundDecMax}