Activemq - 能够连接到其他机器 MySQL 但不能连接到本地机器 MySQL
Active MQ - able to connect to other machine MySQL but not local machine MySQL
我在公司网络中,并在我们的项目中使用 ActiveMQ。我正在尝试将数据保存在 MySQL 而不是默认的 KahaDB 上,并遵循 ActiveMQ home page
上的指南
连接属性如下所示:
<bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/activemq"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
当我通过 bin/win64/wrapper.exe 启动活动的 mq 服务器时,我收到“通信 link 失败”:
2020-09-21 14:56:36,983 | WARN | Could not get JDBC connection: Cannot create PoolableConnectionFactory (Communications link failure
The last packet successfully received from the server was 523 milliseconds ago. The last packet sent successfully to the server was 515 milliseconds ago.) | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure
The last packet successfully received from the server was 523 milliseconds ago. The last packet sent successfully to the server was 515 milliseconds ago.)
at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:669)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:544)
at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:753)
...
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
...
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:187)
我注意到还有一些 'connection' 因为有数据包发送和接收。尽管如此,activemq 服务器还是无法启动。
然而,当我将连接属性更改为登台服务器的 ip 地址时,activemq 成功启动。
我创建了一个片段来尝试使用相同的连接属性连接到本地数据库并且没有抛出错误:
public class ConnectionTest {
public static void main(String[] args) throws SQLException {
try (
BasicDataSource dataSource = new BasicDataSource()) {
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/activemq");
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUsername("activemq");
dataSource.setPassword("");
dataSource.setPoolPreparedStatements(true);
Connection conn = dataSource.getConnection();
conn.close();
}
}
}
在我的代码片段中,我使用了 mysql-connector-java.5.1.49.jar 和 common -dbcp2-2.7.0.jar。这 2 个罐子也在 activemq/lib/optional
我尝试了 127.0.0.1、localhost 和我 PC 的 IP 地址。 None 有效
还有什么其他解决方案可以让活动 mq 使用我的本地数据库?
谢谢:)
感谢@Kevin Boone 指出 SSL 的问题。我在 my.ini 文件中添加了以下内容:
ssl=0
然后重新启动 mysql 服务。现在我的 activeMQ 代理可以连接到本地数据库。
我在公司网络中,并在我们的项目中使用 ActiveMQ。我正在尝试将数据保存在 MySQL 而不是默认的 KahaDB 上,并遵循 ActiveMQ home page
上的指南连接属性如下所示:
<bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/activemq"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
当我通过 bin/win64/wrapper.exe 启动活动的 mq 服务器时,我收到“通信 link 失败”:
2020-09-21 14:56:36,983 | WARN | Could not get JDBC connection: Cannot create PoolableConnectionFactory (Communications link failure
The last packet successfully received from the server was 523 milliseconds ago. The last packet sent successfully to the server was 515 milliseconds ago.) | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure
The last packet successfully received from the server was 523 milliseconds ago. The last packet sent successfully to the server was 515 milliseconds ago.)
at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:669)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:544)
at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:753)
...
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
...
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:187)
我注意到还有一些 'connection' 因为有数据包发送和接收。尽管如此,activemq 服务器还是无法启动。
然而,当我将连接属性更改为登台服务器的 ip 地址时,activemq 成功启动。
我创建了一个片段来尝试使用相同的连接属性连接到本地数据库并且没有抛出错误:
public class ConnectionTest {
public static void main(String[] args) throws SQLException {
try (
BasicDataSource dataSource = new BasicDataSource()) {
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/activemq");
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUsername("activemq");
dataSource.setPassword("");
dataSource.setPoolPreparedStatements(true);
Connection conn = dataSource.getConnection();
conn.close();
}
}
}
在我的代码片段中,我使用了 mysql-connector-java.5.1.49.jar 和 common -dbcp2-2.7.0.jar。这 2 个罐子也在 activemq/lib/optional
我尝试了 127.0.0.1、localhost 和我 PC 的 IP 地址。 None 有效
还有什么其他解决方案可以让活动 mq 使用我的本地数据库? 谢谢:)
感谢@Kevin Boone 指出 SSL 的问题。我在 my.ini 文件中添加了以下内容:
ssl=0
然后重新启动 mysql 服务。现在我的 activeMQ 代理可以连接到本地数据库。