从 WebSphere MQ 迁移到 Active MQ
Migrating from WebSphere MQ to Active MQ
有一个类似的问题Procedure to migrate from IBM MQ to ActiveMQ并且已经关闭,但我还是会尝试。
我们的客户希望从 WebSphere MQ 迁移到 Active MQ。在上面提到的问题中,据说对于 JMS,理论上这种迁移将包括应用程序重新配置。我们的客户说他们的应用程序使用自动生成的 .bindings 文件。那么,是否可以仅通过编辑 .binding 文件并将活动 mq 的 .jars 放入 java 类路径,或者需要一些其他配置来使应用程序与活动 MQ 一起工作?
为了检查这一点,我尝试了以下方法
a) 使用 JMSAdmin 创建 WMQ 绑定文件。一旦我创建了 QCF 和队列,我就能够通过 JMS 查找发送消息并发送消息。
b) 对于设置为生成 .bindings 文件的 AMQ,IBM 提供了一些示例代码 generate the bindings file.
完成此操作后,我使用完全相同的代码发送消息,并且该消息完美地发送到 AMQ 和 WMQ
这是我能够互操作的示例代码。
public void sendMessages() {
ConnectionFactory connectionFactory;
Connection con = null;
Session session = null;
MessageProducer producer = null;
//create initial context properties
Properties initialContextProperties = new Properties();
initialContextProperties.put("java.naming.factory.initial", "com.sun.jndi.fscontext.RefFSContextFactory");
initialContextProperties.put(Context.PROVIDER_URL, "file:/C:/JNDI-Directory/AMQ");
initialContextProperties.setProperty("transport.jms.security.authentication", "none");
try {
InitialContext initialContext = new InitialContext(initialContextProperties);
//create connection factory object
//ivtQCF - created connection factory object in IBM-MQ
connectionFactory = (ConnectionFactory) initialContext.lookup("confact2");
con = connectionFactory.createConnection();
con.start();
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
//localq - created queue in IBM-MQ
Destination destination = (Destination) initialContext.lookup("dest");
producer = session.createProducer(destination);
String msg = "SAMPLE MESSAGE PLACED TO QUEUE";
TextMessage textMessage = session.createTextMessage(msg);
producer.send(textMessage);
con.close();
session.close();
producer.close();
} catch (NamingException e) {
throw new RuntimeException("Unable to send jms messages", e);
} catch (JMSException e) {
throw new RuntimeException("Unable to send jms messages", e);
}
}
有一个类似的问题Procedure to migrate from IBM MQ to ActiveMQ并且已经关闭,但我还是会尝试。 我们的客户希望从 WebSphere MQ 迁移到 Active MQ。在上面提到的问题中,据说对于 JMS,理论上这种迁移将包括应用程序重新配置。我们的客户说他们的应用程序使用自动生成的 .bindings 文件。那么,是否可以仅通过编辑 .binding 文件并将活动 mq 的 .jars 放入 java 类路径,或者需要一些其他配置来使应用程序与活动 MQ 一起工作?
为了检查这一点,我尝试了以下方法
a) 使用 JMSAdmin 创建 WMQ 绑定文件。一旦我创建了 QCF 和队列,我就能够通过 JMS 查找发送消息并发送消息。
b) 对于设置为生成 .bindings 文件的 AMQ,IBM 提供了一些示例代码 generate the bindings file.
完成此操作后,我使用完全相同的代码发送消息,并且该消息完美地发送到 AMQ 和 WMQ
这是我能够互操作的示例代码。
public void sendMessages() {
ConnectionFactory connectionFactory;
Connection con = null;
Session session = null;
MessageProducer producer = null;
//create initial context properties
Properties initialContextProperties = new Properties();
initialContextProperties.put("java.naming.factory.initial", "com.sun.jndi.fscontext.RefFSContextFactory");
initialContextProperties.put(Context.PROVIDER_URL, "file:/C:/JNDI-Directory/AMQ");
initialContextProperties.setProperty("transport.jms.security.authentication", "none");
try {
InitialContext initialContext = new InitialContext(initialContextProperties);
//create connection factory object
//ivtQCF - created connection factory object in IBM-MQ
connectionFactory = (ConnectionFactory) initialContext.lookup("confact2");
con = connectionFactory.createConnection();
con.start();
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
//localq - created queue in IBM-MQ
Destination destination = (Destination) initialContext.lookup("dest");
producer = session.createProducer(destination);
String msg = "SAMPLE MESSAGE PLACED TO QUEUE";
TextMessage textMessage = session.createTextMessage(msg);
producer.send(textMessage);
con.close();
session.close();
producer.close();
} catch (NamingException e) {
throw new RuntimeException("Unable to send jms messages", e);
} catch (JMSException e) {
throw new RuntimeException("Unable to send jms messages", e);
}
}