mysql 使用 mule esb 插入数据库
mysql insert into database with 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,实际上我不知道我的例子有什么问题,请任何一步一步的帮助(比如我错过了什么组件或类似的东西) , 提前谢谢你
HTTPS 的端口是 443
而不是 80
。 host
属性也只是主机,不应在此处放置任何协议。
所以替换这个:
host="https://gist.githubusercontent.com" port="80"
这样:
host="gist.githubusercontent.com" port="443" protocol="HTTPS"
参考material:http://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector
你好,我正在尝试将来自 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,实际上我不知道我的例子有什么问题,请任何一步一步的帮助(比如我错过了什么组件或类似的东西) , 提前谢谢你
HTTPS 的端口是 443
而不是 80
。 host
属性也只是主机,不应在此处放置任何协议。
所以替换这个:
host="https://gist.githubusercontent.com" port="80"
这样:
host="gist.githubusercontent.com" port="443" protocol="HTTPS"
参考material:http://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector