Spring DSL を使用して、JSON 形式のデータを Camel に取得しています。私はこのようなコードを書きました、
<bean id="mqtt" class="org.apache.camel.component.mqtt.MQTTComponent"/>
<bean id="gson" class="org.apache.camel.component.gson.GsonDataFormat"/>
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route>
<camel:from uri="mqtt:bar?host=tcp://10.30.11.0:1883&subscribeTopicName=apss/messages" />
<unmarshal ref="gson" />
<camel:choice>
<camel:when>
<!-- I dont knwo what to write here -->
<camel:to uri="stream:out" />
</camel:when>
<camel:otherwise>
<camel:to uri="stream:out" />
</camel:otherwise>
</camel:choice>
</camel:route>
</camel:camelContext>
最初のフィールドを文字列と比較し、解析後に何をするかを決定します。GSON が JSON 文字列をハッシュマップに解析することはわかっています。したがって、ハッシュマップで get(0) を実行したいと思います。でも、春はどうしたらいいのかわからない。誰でも私を助けることができますか?