首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过mule与amazon SNS api通信时使用Topic对象

通过mule与amazon SNS api通信时使用Topic对象
EN

Stack Overflow用户
提问于 2015-05-05 04:09:22
回答 1查看 342关注 0票数 0

我正在使用Anypoint Studio来试验连接器。现在,我尝试创建一个简单的流程,列出amazon SNS端点上可用的主题,并搜索某个主题是否可用。到目前为止,我可以从API获得带有主题列表的响应,然后使用Object to json转换器将其转换为JSON,但我希望迭代列表以搜索特定的主题(使用java或其他过滤器)。主题实体已经存在于Anypoint Studio的amazon API中,但是我找不到如何将它映射到API返回的响应。任何提示都将不胜感激。编辑:这是流的代码,删除了访问键。

代码语言:javascript
复制
<?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>

EN

回答 1

Stack Overflow用户

发布于 2015-05-05 05:01:59

您从sns:list-topics获得的消息有效负载是一个com.amazonaws.services.sns.model.ListTopicsResult

因此,可以使用MEL转换器使用如下表达式过滤主题列表:

代码语言:javascript
复制
($ in message.payload.topics if $.topicArn contains 'my-topic')

参考:Projections and folds in MVEL 2.0

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30039071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档