I have an application that uses JNI to execute some legacy code I wrote a 
million years ago.  It is not reentrant so I prefer to execute it outside of 
jboss. I have implemented this inside jboss and it works there but has 
concurrency issues that can really cause problems with jboss. 

I can bring up an openjms server on port 6969 (i know i am a cad) and I can 
execute my stuff via queue on this server.  I am able to run an example on my 
openjms server but I can't for the life of me figure out how to configure this 
properly so I can connect to the openjms server via jboss.

I have a feeling that this is a problem with adding some jndi configuration to 
the following files:

jms-ds.xml
standardjboss.xml (possibly)

Could someone help me out here on what the steps are to get this working?

Below is the send code I am using inside jboss.  

public static String sendMyMessage(Serializable payload, String 
connectionFactoryJndiName, String destinationJndiName) throws 
JmsProducerException 
    {
        String replyString = null;
                String result;
                Context jndiContext = null;
                QueueConnectionFactory factory = null;
                QueueConnection connection = null;
                QueueConnection Rconnection = null;
                String factoryName = "openJMSProvider";
                String destName = "ReadResults";
                String modelName = null;
                String xmlName = null;
                boolean runQuickLook = false;
                Queue dest = null;
                Queue queueDest = null;
                QueueSession session = null;
                QueueSession Rsession = null;
                QueueSender sender = null;
                String text = "";
                boolean runTest = false;
                Queue clientQueue = null;
        
                try
                {
                        System.out.println("1 Here");
                jndiContext = new InitialContext();
                        // look up the ConnectionFactory
                        System.out.println("2 Here");
                        factory = 
(QueueConnectionFactory)jndiContext.lookup(factoryName);

                        // look up the Destination
                        System.out.println("3 Here");
                        dest = (Queue)jndiContext.lookup(destName);

                        // create the connection
                        System.out.println("4 Here");
                        connection = factory.createQueueConnection();

                        // create the session
                        System.out.println("5 Here");
                        session = connection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);

                        // create the sender
                        System.out.println("6 Here");
                        sender = session.createSender(dest);

                        // Create Receiver Connection

                        System.out.println("7 Here");
                        Rconnection = factory.createQueueConnection();
                        Rsession = connection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
                        clientQueue = Rsession.createTemporaryQueue();
                        //clientQueue = 
Rsession.createQueue("PAFSClientListenerQueue");
//                      clientQueue = 
(Queue)jndiContext.lookup("PAFSClientListenerQueue");
//                      clientQueue = (Queue)jndiContext.lookup("ReadResults");


                        // start the connection, to enable message sends
                        connection.start();
                        Message message = session.createObjectMessage(payload);
                        
                        message.setJMSReplyTo(clientQueue); 
                        sender.send(message);
                        Message msg = null;
                        String messageID = message.getJMSMessageID();
                        String myFilter = "JMSCorrelationID = '" + messageID + 
"'";

                        
                        QueueReceiver qReceiver = null;
                        qReceiver = Rsession.createReceiver(clientQueue, 
myFilter);
                        System.out.println("  Wait for reply msg...");
                        Rconnection.start();
                        msg = qReceiver.receive(15000);

                        if (msg == null)
                        {
                                replyString = "No reply message retrieved, 
queue timeout\n";
                                result = "No reply message retrieved, queue 
timeout\n";
                        }
                        else
                        {

                                if (msg instanceof TextMessage)
                                {
                                        replyString = 
((TextMessage)msg).getText();
                                        result = "Reply Success";

                                }
                                else
                                {
                                        replyString = "Reply not text message";
                                        result = "Reply not text message";
                                }
                        }
                        System.out.println("  Server reply: " + result + "\n 
Server Result: \n" + replyString);
 
        } // end of try  
                catch (JMSException exception) 
                {
                        exception.printStackTrace();
                } 
                catch (NamingException exception) 
                {
                        exception.printStackTrace();
                } 
                finally 
                {
                        // close the context
                        if (jndiContext != null) 
                        {
                                try 
                                {
                                        jndiContext.close();
                                } 
                                catch (NamingException exception) 
                                {
                                        exception.printStackTrace();
                                }
                        }
                }// end of finally
        // close the connection
        if (connection != null) 
                {
            try 
                        {
                connection.close();
            } 
                        catch (JMSException exception) 
                        {
                exception.printStackTrace();
            }
        }
                if (Rconnection != null)
                {
                        try
                        {
                                Rconnection.close();
                        }
                        catch (JMSException exception)
                        {
                                exception.printStackTrace();
                        }
                }

                return replyString;
    } // end of method
     

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974675#3974675

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974675
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to