【问题标题】:WSO2 Stream processor Integrating with mysql database is not workingWSO2流处理器与mysql数据库集成不起作用
【发布时间】:2018-11-05 07:30:38
【问题描述】:

我正在尝试通过 siddhi 应用程序连接 mysql 服务器,并按照以下文档链接进行设置。 https://docs.wso2.com/display/SP430/Integrating+Datastores

但是当我运行 siddhi 应用程序时,我收到以下错误,

[2018-11-05_05-22-38_825] INFO {org.wso2.carbon.siddhi.editor.core.internal.WorkspaceDeployer} - Siddhi App ShipmentHistoryApp successfully deployed. 
ShipmentHistoryApp.siddhi - Started Successfully!
[2018-11-05_05-22-46_761] ERROR {org.wso2.siddhi.core.table.Table} - Error on 'ShipmentHistoryApp'. Exception during pool initialization: Communications link failure__The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. . Error while connecting to Table 'ShipmentDetails'. (Encoded)
com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.zaxxer.hikari.pool.HikariPool.initializeConnections(HikariPool.java:581)
    at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:152)
    at com.zaxxer.hikari.HikariDataSource.(HikariDataSource.java:73)
    at org.wso2.extension.siddhi.store.rdbms.RDBMSEventTable.initializeDatasource(RDBMSEventTable.java:1002)
    at org.wso2.extension.siddhi.store.rdbms.RDBMSEventTable.connect(RDBMSEventTable.java:795)
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:455)
    ... 21 more
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
Caused by: java.net.SocketException: Broken pipe (Write failed)
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
    at sun.security.ssl.OutputRecord.writeBuffer(OutputRecord.java:431)
    at sun.security.ssl.OutputRecord.write(OutputRecord.java:417)
    at sun.security.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:879)
    at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:850)
    at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:720)
[2018-11-05_05-22-46_762] ERROR {org.wso2.siddhi.core.SiddhiAppRuntime} - Error starting Siddhi App 'ShipmentHistoryApp', triggering shutdown process. Exception during pool initialization: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

下面是我在 WSO2 流处理器工作室创建的 siddhi 应用,

@app:name('ShipmentHistoryApp')

@source(type = 'http', receiver.url='http://localhost:8280/ShipmentHistoryApp/RawMaterialStream', @Map(type = 'json'))
define stream RawMaterialStream(name string, supplier string, amount double);

@PrimaryKey('name')
@index('supplier')
@store(type='rdbms', jdbc.url="jdbc:mysql://localhost:3306/SweetFactoryDB", username="root", password="root@123" , jdbc.driver.name="com.mysql.cj.jdbc.Driver")
define table ShipmentDetails(name string, supplier string, amount double);

from RawMaterialStream
select name, supplier, amount
insert into ShipmentDetails;

下面是我在编辑器deployment.yaml中定义的mysql配置

  - name: SweetFactoryDB
    description: Datasource used for Sweet Factory Supply Records
    jndiConfig:
      name: jdbc/SweetFactoryDB
      useJndiReference: true
    definition:
      type: RDBMS
      configuration:
        jdbcUrl: 'jdbc:mysql://siddhi:3306/SweetFactoryDB'
        username: root
        password: root@123
        driverClassName: com.mysql.cj.jdbc.Driver
        maxPoolSize: 50
        idleTimeout: 60000
        connectionTestQuery: SELECT 1
        validationTimeout: 30000
        isAutoCommit: false

我尝试将 mysql 驱动程序转换为 OSGI(使用 jartobundle.sh),然后再放入 /lib 目录:

misra_debasish91@siddhi:/usr/lib/wso2/wso2sp/4.3.0$ sh /usr/lib/wso2/wso2sp/4.3.0/bin/jartobundle.sh mysql-connector-java-8.0.13.jar lib/
JAVA_HOME environment variable is set to /usr/lib/jvm/java-8-oracle
CARBON_HOME environment variable is set to /usr/lib/wso2/wso2sp/4.3.0
Nov 05, 2018 7:00:41 AM org.wso2.carbon.tools.converter.utils.BundleGeneratorUtils convertFromJarToBundle
WARNING: Path /usr/lib/wso2/wso2sp/4.3.0/mysql-connector-java-8.0.13.jar refers to an OSGi bundle
Nov 05, 2018 7:00:41 AM org.wso2.carbon.tools.converter.utils.BundleGeneratorUtils convertFromJarToBundle
INFO: Created the OSGi bundle mysql_connector_java_8.0.13_1.0.0.jar for JAR file /usr/lib/wso2/wso2sp/4.3.0/mysql-connector-java-8.0.13.jar

如果我在设置中做错了什么,请帮助我解决错误并纠正我。

谢谢!!

【问题讨论】:

    标签: wso2 wso2sp


    【解决方案1】:

    上述配置中需要纠正的地方很少。在@store 注释内的共享 Siddhi 应用程序中,您将提供所有数据库参数以创建数据库连接。这是连接到商店的一种模式。另一种方法是在deployment.yaml文件中定义一个数据源并使用它。由于您已经在线定义了商店,因此我们首先删除您在 deployment.yaml 中添加的数据源定义。我的猜测是日志中的这个连接问题是由于 URL jdbc:mysql://siddhi:3306/SweetFactoryDB 因为主机名 siddhi 无法解析而发生的。

    另外一点需要注意的是,最近的 mqsql 驱动程序已经 OSGified。所以请检查特定的驱动程序 jar 是否已经是 OSGi 包。在这种情况下,您不需要转换。

    通过以上提示和共享文档,您应该能够满足您的要求。

    【讨论】:

    • 是的,我已经删除了 deployment.yaml 文件中的数据源,并将 siddhi 的主机名更改为 localhost,下面是错误,{org.wso2.carbon.siddhi.editor. core.internal.DebuggerEventStreamService} - 将事件推送到 Siddhi 调试器引擎 com.zaxxer.hikari.pool.PoolInitializationException 时出错:池初始化期间出现异常:无法创建与数据库服务器的连接。尝试重新连接 3 次。放弃。无法创建与数据库服务器 javax.net.ssl.SSLHandshakeException 的连接:收到致命警报:unknown_ca 告诉我您的想法。
    • 为数据源 URL 添加 ?useSSL=false 参数。例如:jdbc:mysql://siddhi:3306/SweetFactoryDB?useSSL=false
    【解决方案2】:

    我遇到了同样的问题。为我工作的数据源添加 ?useSSL=false 参数。 Aurora RDS中的Mysql

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-29
    • 2021-09-13
    相关资源
    最近更新 更多