-1

There was a similar question Procedure to migrate from IBM MQ to ActiveMQ and it was closed, but I will try anyway. Our customers want to migrate from WebSphere MQ to Active MQ. In above mentioned question it was said that as for JMS such migration in theory will consist in apps re-configuration. Our customers say that their apps use auto-generated .bindings file. So, is it possible to make apps work with Active MQ just by editing .binding file and putting active mq's .jars to java classpath, or some other configuration is required?

Community
  • 1
  • 1
kseniyam
  • 95
  • 1
  • 5

1 Answers1

2

To check this , i tried the following

a) Create a WMQ bindings file use JMSAdmin. Once i created a QCF and Queue i was able to send a message via a JMS lookup and send a message.

b) For the AMQ set up to generate a .bindings file , IBM had some sample code to generate the bindings file.

Once this was done i used exactly the same code to send a message and the message was perfectly sent to both AMQ and WMQ

Here is the sample code that i was able to interoperate.

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);
        }
    }
Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • I'm very, I'm not a java-programmer, and I'm not aware of java ecosystem. 1.It is said there that fscontext.jar and providerutil.jar are required for JNDI lookup. Where can I found them? – kseniyam Sep 26 '16 at 08:24
  • 1
    You can download them from a Maven repo for example : https://mvnrepository.com/artifact/com.sun.jndi/fscontext/1.2-beta-3 has a Download JAR option. Same with providerutil as well – Ramachandran.A.G Sep 26 '16 at 08:26
  • 2. It is said there to copy bindings file from activemq server? but there is no any binding file in the distribution. Or is ActiveMQBindingsCreation.java used to generate bindings file? (the code in it does not seem to do that). Will be very grateful if you help to clarify. – kseniyam Sep 26 '16 at 08:30
  • i put all jars to classpath, but when i try to run java cod i get: Could not create JNDI context: javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory] – kseniyam Sep 26 '16 at 10:09
  • it was my mistakes with jndi exception. i used wrong jars. – kseniyam Sep 26 '16 at 10:25
  • i generated bindings file! hooray! – kseniyam Sep 26 '16 at 10:26
  • one more question. Do I need to recompile the app to enable new bindings? – kseniyam Sep 27 '16 at 19:18
  • The link in b) is dead. – Stephen Kennedy Jun 09 '18 at 17:36