我正在尝试编写一个使用Box连接器的Mule流程。我可以去http://localhost:8081/auth
并成功授权。但是当我在我的盒子帐户中创建一个文件时,我得到“无法调用getEvents。消息有效内容的类型为:String。”在根异常跟踪中,我得到:“无效密钥类型”
骡流(基于:https://github.com/mulesoft/box-connector/blob/master/demo/src/main/app/box-connector-demo.xml)
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:box="http://www.mulesoft.org/schema/mule/box" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd
http://www.mulesoft.org/schema/mule/box http://www.mulesoft.org/schema/mule/box/2.0/mule-box.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<box:config name="Box" clientId="removed" clientSecret="removed" doc:name="Box">
<box:oauth-callback-config domain="localhost" localPort="8081" path="callback" remotePort="8081"/>
</box:config>
<objectstore:config name="ObjectStore" objectStore-ref="_defaultInMemoryObjectStore" doc:name="ObjectStore"/>
<flow name="Authorize" doc:name="Authorize">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="auth"/>
<box:authorize config-ref="Box" doc:name="Authorize" />
</flow>
<flow name="longPolling" doc:name="longPolling">
<box:listen-events config-ref="Box" doc:name="Box (Streaming)"/>
<set-variable variableName="defaultValue" value="0" doc:name="Variable"/>
<objectstore:retrieve config-ref="ObjectStore" key="streamPosition" defaultValue-ref="#[flowVars['defaultValue']]" doc:name="ObjectStore"/>
<box:get-events config-ref="Box" streamPosition="#[payload]" accessTokenId="#[message.inboundProperties['boxAccessTokenId']]" doc:name="Box" />
<objectstore:store config-ref="ObjectStore" key="streamPosition" value-ref="#[payload.nextStreamPosition]" overwrite="true" doc:name="ObjectStore"/>
<scripting:transformer doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[return payload.entries.findAll{it.eventType =='ITEM_DOWNLOAD' || it.eventType == 'ITEM_PREVIEW'}
]]></scripting:script>
</scripting:transformer>
<scripting:transformer doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[return payload.findAll{it.source?.type == "file" && it.source?.parent.id == "0"}
]]></scripting:script>
</scripting:transformer>
<foreach doc:name="Foreach">
<logger message="Box user #[payload.createdBy.login] has seen the file #[payload.source.name]" level="ERROR" doc:name="Logger"/>
</foreach>
</flow>
</mule>
这是完整的错误:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'boxtest' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
WARN 2014-02-06 10:00:35,607 [Box Long Polling thread for endpont http://2.realtime.services.box.net/subscribe?channel=removed&stream_type=all] org.mule.DefaultMuleMessage: setProperty(key, value) called with null value; removing key: boxAccessTokenId; please report the following stack trace to dev@mule.codehaus.org
java.lang.Throwable
at org.mule.DefaultMuleMessage.setProperty(DefaultMuleMessage.java:457)
at org.mule.DefaultMuleMessage.addProperties(DefaultMuleMessage.java:1249)
at org.mule.DefaultMuleMessage.<init>(DefaultMuleMessage.java:174)
at org.mule.modules.box.processors.AbstractListeningMessageProcessor.process(AbstractListeningMessageProcessor.java:76)
at org.mule.modules.box.lp.LongPollingClient$1.run(LongPollingClient.java:63)
at java.lang.Thread.run(Unknown Source)
ERROR 2014-02-06 10:00:35,823 [[boxtest].longPolling.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke getEvents. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Invalid key type (java.lang.RuntimeException)
org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory:28 (null)
2. Failed to invoke getEvents. Message payload is of type: String (org.mule.api.MessagingException)
org.mule.modules.box.processors.GetEventsMessageProcessor:155 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.RuntimeException: Invalid key type
at org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory.makeObject(BoxConnectorOAuthClientFactory.java:28)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1179)
at org.mule.modules.box.oauth.BoxConnectorOAuthManager.acquireAccessToken(BoxConnectorOAuthManager.java:339)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
答案 0 :(得分:1)
这看起来像是一个bug:box:get-events应该使用属性boxAccessTokenId作为身份验证令牌,有一个警告,由于null值,属性未设置,当我查看源代码时对于值来自的BoxConnector类,有一个从未设置的私有变量accessTokenIdentifier的引用。我把这个报告给了Mule dev地址。
答案 1 :(得分:0)
...我最近在Mule 3.x和4.x运行时中都使用了Box连接器。一旦了解了所需内容,我对设置的简易性感到满意。
我建议立即尝试。