我正在使用Anypoint Studio来试验连接器。现在,我尝试创建一个简单的流程,列出amazon SNS端点上可用的主题,并搜索某个主题是否可用。到目前为止,我可以从API获得带有主题列表的响应,然后使用Object to json转换器将其转换为JSON,但我希望迭代列表以搜索特定的主题(使用java或其他过滤器)。主题实体已经存在于Anypoint Studio的amazon API中,但是我找不到如何将它映射到API返回的响应。任何提示都将不胜感激。编辑:这是流的代码,删除了访问键。
<?xml version="1.0" encoding="UTF-8"?>
<sns:config name="Amazon_SNS" accessKey="" secretKey="" doc:name="Amazon SNS" region="EUWEST1">
<sns:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</sns:config>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<json:object-to-json-transformer name="Object_to_JSON" doc:name="Object to JSON"/>
<flow name="CreateTopic">
<http:listener config-ref="HTTP_Listener_Configuration" path="/createtopic" doc:name="HTTP"/>
<sns:create-topic config-ref="Amazon_SNS" doc:name="Amazon SNS">
<sns:create-topic-request name="#[message.inboundProperties.'http.query.params'.name]"/>
</sns:create-topic>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="Subscribe">
<http:listener config-ref="HTTP_Listener_Configuration" path="/Subscribe" doc:name="HTTP"/>
<sns:subscribe config-ref="Amazon_SNS" doc:name="Amazon SNS">
<sns:subscribe-request topicArn="#[message.inboundProperties.'http.query.params'.topic]" protocol="email" endpoint="#[message.inboundProperties.'http.query.params'.subscriber]"/>
</sns:subscribe>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="ListTopics">
<http:listener config-ref="HTTP_Listener_Configuration" path="/listTopics" doc:name="HTTP"/>
<sns:list-topics config-ref="Amazon_SNS" doc:name="Amazon SNS">
</sns:list-topics>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="Publish">
<http:listener config-ref="HTTP_Listener_Configuration" path="/publish" doc:name="HTTP"/>
<sns:publish config-ref="Amazon_SNS" doc:name="Amazon SNS">
<sns:publish-request topicArn="#[message.inboundProperties.'http.query.params'.topic]" message="There's new content in the topic #[message.inboundProperties.'http.query.params'.topic]" subject="New comments on an idea - Crowdsourcing Forums" messageStructure="Raw"/>
</sns:publish>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="checkTopic">
<http:listener config-ref="HTTP_Listener_Configuration" path="/checkTopic" doc:name="HTTP"/>
<sns:get-topic-attributes config-ref="Amazon_SNS" doc:name="Amazon SNS">
<sns:get-topic-attributes-request topicArn="#[message.inboundProperties.'http.query.params'.topic]"/>
</sns:get-topic-attributes>
</flow>
发布于 2015-05-05 05:01:59
您从sns:list-topics获得的消息有效负载是一个com.amazonaws.services.sns.model.ListTopicsResult。
因此,可以使用MEL转换器使用如下表达式过滤主题列表:
($ in message.payload.topics if $.topicArn contains 'my-topic')参考:Projections and folds in MVEL 2.0
https://stackoverflow.com/questions/30039071
复制相似问题