Making a JMS connection to LMG/LMB

I've been trying to create a JMS connection to LMB so that I can eventually send messages to the Grade Adapeter.

I've been running into problems creating the QueueConnectionFactory. When I use the bit of code:

QueueConnectionFactory conFactory = (QueueConnectionFactory)jndi.lookup("cn=MBInternalQueueConnectionFactory,ou=AdministeredObjects");

I get a ClassCastException. I looked, and the jndi.lookup apprears to be returning an object with the class com.sct.pipeline.jms.QueueConnectionFactory. Does anybody know where I find the jar that would contain that? Does anybody have a full snippet of code where you create a JMS connection to LMB?

I found a few helpful posts (like http://www.lumdev.net/node/1078) here that have gotten me to where I am now, but I've hit a dead end at the moment.

 

Thanks,
-Eric Merrill
Oakland University

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Queue connection factory

Did you try using the mbldisetup/webct_mbldisetup script instead of creating them by hand?

If you need to create them by hand you might be able to use the script to get clues on how to do it.

LMB already setup

I think you misunderstand me. LMB is already fully setup. I need to connect to the existing Queues/Topics. As I try to create the connections I get errors.

Thanks,
-Eric

Topic versus Queue

We connect to JMS and consume / publish messages, but it is though the Topics (not Queues) that are already created by Luminis.  Theya re durable subscriptions, so no messages are lost.  Not sure why you're using a queue?

Anyway, here is some code for you, it might help:



    public MessagePublisher(CrosslistAdapter xla, String tn, String user, String pass, boolean d) {
        TopicConnectionFactory  topicConnectionFactory = null;
        topicName = new String(tn);
        cAdapter = xla;
        debug = d;

        try {
            topicConnectionFactory = Utilities.getTopicConnectionFactory();
            topicConnection = topicConnectionFactory.createTopicConnection(user,pass);
            topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topic = Utilities.getTopic(topicName, topicSession);
            topicPublisher = topicSession.createPublisher(topic);
        } catch (Exception e) {
            System.out.println("Connection problem: " + e.toString());
            if (topicConnection != null) {
                try {
                    topicConnection.close();
                } catch (JMSException ee) {}
            }
            cAdapter.setError(1);
        }
    }


    public void publishMessage(TextMessage message) {
        try {
            System.out.println("PUBLISHER: Publishing message to "+topicName);
            topicPublisher.publish(message);
            String pubXML =  message.getText();
            if (debug) {System.out.println("Published XML:\n"+pubXML+"\n");}

            // Send a non-text control message indicating end of messages.
            topicPublisher.publish(topicSession.createMessage());
        } catch (JMSException e) {
            System.out.println("Exception occurred: " + e.toString());
            cAdapter.setError(1);
        }
    }

The reason we are trying to

The reason we are trying to use queues is because the default Grade Adapter interface ( com_sct_ldi_sis_UpdateRequest) is a queue.

But even so, I can't seem to make an useful connection. My question about your code, is where does Utilities come from? Is it a modified version of the Java SampleUtilities, and if so, how did you modify it?

Thanks
-Eric

I'm also mainly feeling like

I'm also mainly feeling like I'm missing a class that I need. What do you import at the top of your file?

Thanks again,
-Eric

Code

OK I have made a new entry for you and published the full code there:

http://www.lumdev.net/node/3382

Todd

Thank you very much for the

Thank you very much for the help. It helped me make some forward progress.

Thanks,
-Eric

Syndicate content