我不确定我想要做的事情是否可行,但基本上我正在尝试使用Artemis将当前的实现从HornetQ更新到ActiveMQ。
我的系统是来自HornetQ的JMS消费者。
如果我使用"HornetQJMSConnectionFactory",则当前的实现有效,但是当我更改为ActiveMQJMSConnectionFactory时,它无法连接。
为了测试新的实现,我已经启动了ActiveMQ的本地实例并使用新的实现。
所以我尝试了多种不同的东西,包括强制协议=HORNETQ,但没有任何效果。
没有编译错误,"仅":
ERROR o.s.j.l.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful - Could not refresh JMS Connection for destination 'QueueX' - retrying using FixedBackOff{interval=5000, currentAttempts=1, maxAttempts=unlimited}. Cause: Failed to create session factory; nested exception is ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ219013: Timed out waiting to receive cluster topology. Group:null]
旧实现
private ConnectionFactory createConnectionFactory(SyncProperties.SmpJmsServer jmsServer) {
final String className = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory";
Map<String, Object> params = new HashMap<String, Object>();
params.put("host", getJmsHost());
params.put("port", getJmsPort());
TransportConfiguration transportConfiguration = new TransportConfiguration(className, params);
HornetQJMSConnectionFactory hornetQJMSConnectionFactory = new HornetQJMSConnectionFactory(false, transportConfiguration);
hornetQJMSConnectionFactory.setConnectionTTL(300000);
hornetQJMSConnectionFactory.setConsumerWindowSize(0);
UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter();
adapter.setTargetConnectionFactory(hornetQJMSConnectionFactory);
adapter.setUsername(getJmsUsername());
adapter.setPassword(getJmsPassword());
CachingConnectionFactory smpCachingConnectionFactory = new CachingConnectionFactory(adapter);
return smpCachingConnectionFactory;
}
新实施
public ConnectionFactory createActiveMQJMSConnectionFactory() {
ActiveMQJMSConnectionFactory activeMQJMSConnectionFactory = new ActiveMQJMSConnectionFactory(false, amqTransportConfiguration());
activeMQJMSConnectionFactory.setConnectionTTL(300000);
activeMQJMSConnectionFactory.setConsumerWindowSize(0);
UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter();
adapter.setTargetConnectionFactory(activeMQJMSConnectionFactory);
adapter.setUsername(getJmsUsername());
adapter.setPassword(getJmsPassword());
CachingConnectionFactory smpCachingConnectionFactory = new CachingConnectionFactory(adapter);
return smpCachingConnectionFactory;
}
@Bean("amqTransportConfiguration")
public TransportConfiguration amqTransportConfiguration() {
return new TransportConfiguration("org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory", getParams());
}
static Map<String, Object> getParams() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("host", getJmsHost());
params.put("port", getJmsPort());
return params;
}
感谢您的帮助。
虽然ActiveMQ Artemis是基于HornetQ代码库的,但ActiveMQ Artemis客户端将无法与HornetQ代理通信。每个客户端在连接时发送一个协议/客户端标识符。这个ID在ActiveMQ Artemis客户端和HornetQ客户端之间是不同的。HornetQ服务器无法识别ActiveMQ Artemis客户端发送的ID,因此不会完成握手。
也就是说,我们已经努力确保HornetQ客户端仍然可以与ActiveMQ Artemis代理进行通信。这就是org.apache.activemq.artemis.core.protocol.hornetq.HornetQProtocolManager
所提供的。
无论如何,升级您的客户无论如何都不会对您有太大帮助。如果你想升级任何东西,我建议你升级EAP,甚至移动到ActiveMQ Artemis的独立版本,这样你就可以获得最新的修复和功能。