mysql使用mule esb插入数据库

时间:2015-03-23 11:33:31

标签: mule esb

你好我正在尝试将来自https://gist.githubusercontent.com/Rajeun/9afed4a50d2158651d6b/raw/88c7c596f3cfda48b17b76a1e12c70adf355e94d/test.json的流插入到我的数据库中,因为我正在使用http请求连接器,Json来对象,数据库连接器,最后是一个记录器,其中有一条消息可以。下面你可以找到配置xml:

## <mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" 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.6.1"
        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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<http:request-config name="HTTP_Request_Configuration" host="https://gist.githubusercontent.com" port="80" doc:name="HTTP Request Configuration" protocol="HTTPS"/>
        <db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="mulesoft" doc:name="MySQL Configuration"/>

        <flow name="testFlow">
  <poll doc:name="Poll">
        <http:request config-ref="HTTP_Request_Configuration" path="Rajeun/9afed4a50d2158651d6b/raw/88c7c596f3cfda48b17b76a1e12c70adf355e94d/test.json" method="GET" doc:name="HTTP"/>
    </poll>            <json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
        <response>
            <logger message="its ok" level="INFO" doc:name="Logger"/>
        </response>
        <response>
            <db:insert config-ref="MySQL_Configuration" doc:name="Database">
                <db:parameterized-query><![CDATA[INSERT INTO push(token, tel, email) VALUES (2,3,#[payload['email']])]]></db:parameterized-query>
            </db:insert>
        </response>
        </flow>
    </mule> ##

应用程序已部署,然后出现错误循环。

## ERROR 2015-03-23 11:17:28,672 [pool-13-thread-1] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Error sending HTTP request. Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.nio.channels.UnresolvedAddressException)
  sun.nio.ch.Net:-1 (null)
2. java.nio.channels.UnresolvedAddressException (java.util.concurrent.ExecutionException)
  org.glassfish.grizzly.impl.SafeFutureImpl$Sync:363 (null)
3. java.util.concurrent.ExecutionException: java.nio.channels.UnresolvedAddressException (java.io.IOException)
  org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:274 (null)
4. Error sending HTTP request. Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.http.internal.request.DefaultHttpRequester:190 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.nio.channels.UnresolvedAddressException
    at sun.nio.ch.Net.checkAddress(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
    at org.glassfish.grizzly.nio.transport.TCPNIOConnectorHandler.connectAsync(TCPNIOConnectorHandler.java:133)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)##

我对mule studio非常新,我正在使用Mule Studio CE,实际上我不知道我的例子有什么问题请一步一步帮助(比如我错过了什么组件或类似的东西),谢谢你提前

1 个答案:

答案 0 :(得分:0)

HTTPS的端口为443而不是80。此外,host属性只是主机,不应该在那里放置任何协议。

所以替换这个:

host="https://gist.githubusercontent.com" port="80"

与此:

host="gist.githubusercontent.com" port="443" protocol="HTTPS"

参考资料:http://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector