Mule ESB Google云消息传递

时间:2014-01-23 08:40:07

标签: mule google-cloud-messaging

我正在尝试创建一个通过Google云消息传递服务发送推送通知的流程。我使用了骡子连接器gcm。但是我无法让它发挥作用。我的配置:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:gcm="http://www.mulesoft.org/schema/mule/gcm" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/gcm http://www.mulesoft.org/schema/mule/gcm/1.0/mule-gcm.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <gcm:config name="Google_Cloud_Messaging" apiKey="BLANK FOR POSTING" doc:name="Google Cloud Messaging"/>
    <flow name="GCMFlow1" doc:name="GCMFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9000" path="gcm" doc:name="HTTP"/>
        <gcm:send-message config-ref="Google_Cloud_Messaging" doc:name="Google Cloud Messaging">
        <gcm:registration-ids>
            <gcm:registration-id>"APA91bGFeuXKNWuAkaFquqk0Dk45kkb-dBZdo_DLz8Ai8bLkZroQyBcDgw-SrA_B2aw2mnReO78rb9ivvn1Phu2x-eMWJmHmtLEOceC-hBGGQvbbpCvse2ZxvllJkYVP-G-jQrfOLOMF"</gcm:registration-id>
        </gcm:registration-ids>
    </gcm:send-message>
    </flow>
</mule>

我收到以下错误:

Exception stack is:
1. Numeric value (5587416482739805649) out of range of int
 at [Source: org.mule.transport.http.ReleasingInputStream@1318bd3c; line: 1, column: 36] (org.codehaus.jackson.JsonParseException)
  org.codehaus.jackson.JsonParser:1433 (null)
2. Failed to invoke sendMessage. Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.gcm.processors.SendMessageMessageProcessor:236 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.codehaus.jackson.JsonParseException: Numeric value (5587416482739805649) out of range of int
 at [Source: org.mule.transport.http.ReleasingInputStream@1318bd3c; line: 1, column: 36]
    at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
    at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
    at org.codehaus.jackson.impl.JsonParserBase.convertNumberToInt(JsonParserBase.java:829)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

我的api密钥和注册ID一样,因为我在别处测试过它们。

更新:详细调试输出:

********************************************************************************
Message               : Failed to invoke sendMessage. Message payload is of type: String
Type                  : org.mule.api.MessagingException
Code                  : MULE_ERROR--2
Payload               : "1"
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Numeric value (8947223409733149407) out of range of int
 at [Source: org.mule.transport.http.ReleasingInputStream@669b824; line: 1, column: 36] (org.codehaus.jackson.JsonParseException)
  org.codehaus.jackson.JsonParser:1433 (null)
2. Failed to invoke sendMessage. Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.gcm.processors.SendMessageMessageProcessor:236 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
org.codehaus.jackson.JsonParseException: Numeric value (8947223409733149407) out of range of int
 at [Source: org.mule.transport.http.ReleasingInputStream@669b824; line: 1, column: 36]
    at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
    at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
    at org.codehaus.jackson.impl.JsonParserBase.convertNumberToInt(JsonParserBase.java:829)
    at org.codehaus.jackson.impl.JsonParserBase.getIntValue(JsonParserBase.java:625)
    at org.codehaus.jackson.map.deser.std.StdDeserializer._parseInteger(StdDeserializer.java:303)
    at org.codehaus.jackson.map.deser.std.StdDeserializer$IntegerDeserializer.deserialize(StdDeserializer.java:819)
    at org.codehaus.jackson.map.deser.std.StdDeserializer$IntegerDeserializer.deserialize(StdDeserializer.java:806)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1909)
    at org.mule.module.gcm.GcmConnector.sendMessage(GcmConnector.java:146)
    at org.mule.module.gcm.processors.SendMessageMessageProcessor$1.process(SendMessageMessageProcessor.java:225)
    at org.mule.module.gcm.adapters.GcmConnectorProcessAdapter$1.execute(GcmConnectorProcessAdapter.java:36)
    at org.mule.module.gcm.processors.SendMessageMessageProcessor.process(SendMessageMessageProcessor.java:211)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:101)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:112)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:47)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:61)
    at org.mule.execution.MessageProcessorExe...
********************************************************************************

新更新的流程

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:gcm="http://www.mulesoft.org/schema/mule/gcm" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/gcm http://www.mulesoft.org/schema/mule/gcm/1.0/mule-gcm.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <gcm:config name="Google_Cloud_Messaging" apiKey="my_key" doc:name="Google Cloud Messaging"/>
    <flow name="GCMFlow1" doc:name="GCMFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9001" path="gcm" doc:name="HTTP"/>
        <set-payload value="APA91bGFeuXKNWuAkaFquqk0Dk45kkb-dBZdo_DLz8Ai8bLkZroQyBcDgw-SrA_B2aw2mnReO78rb9ivvn1Phu2x-eMWJmHmtLEOceC-hBGGQvbbpCvse2ZxvllJkYVP-G-jQrfOLOMF" doc:name="Set Payload"/>
        <expression-component doc:name="Expression"><![CDATA[ArrayList idRegID = new ArrayList();
 idRegID.add("APA91bGFeuXKNWuAkaFquqk0Dk45kkb-dBZdo_DLz8Ai8bLkZroQyBcDgw-SrA_B2aw2mnReO78rb9ivvn1Phu2x-eMWJmHmtLEOceC-hBGGQvbbpCvse2ZxvllJkYVP-G-jQrfOLOMF");
payload= idRegID;]]></expression-component>
        <gcm:send-message config-ref="Google_Cloud_Messaging" doc:name="Google Cloud Messaging">
            <gcm:registration-ids ref="#[payload]"/>
        </gcm:send-message>
    </flow>
</mule>

1 个答案:

答案 0 :(得分:1)

您使用的是旧版本的连接器:您遇到的问题是fixed 7 months ago。您需要升级到更新版本。

对于第二个问题,您已添加到您的问题中:您不需要创建列表,而是使用XML元素:

<gcm:send-message ...
  <gcm:registration-ids>
    <gcm:registration-id>...</gcm:registration-id>
  </gcm:registration-ids>
  ...

PS。你的gcm:registration-id看起来很奇怪。它周围的""可能会消失。

相关问题