Note that there are some explanatory texts on larger screens.

plurals
  1. POReceiving JMS messages from remote GlassFish server
    primarykey
    data
    text
    <p>I'm trying to receive JMS messages from a GlassFish (2.1) server remotely. I have followed the instructions here: <a href="http://www.tidytutorials.com/2009/06/jms-example-using-glassfish-and-remote.html" rel="nofollow">http://www.tidytutorials.com/2009/06/jms-example-using-glassfish-and-remote.html</a> and also here: <a href="http://www.novell.com/documentation/extend52/Docs/help/MP/jms/tutorial/pointToPoint-1.htm" rel="nofollow">http://www.novell.com/documentation/extend52/Docs/help/MP/jms/tutorial/pointToPoint-1.htm</a> but it doesn't seem to work.</p> <p>I have created the QueueConnectionFactory sampleFactory and the Queue sampleQueue for testing. </p> <p>I use the following code to send the message:</p> <pre><code>HashMap&lt;String,List&lt;String&gt;&gt; values = getValues(); InitialContext context = new InitialContext(); QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup("sampleFactory"); Queue queue = (Queue) context.lookup("sampleQueue"); queueConnection = factory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueSender = queueSession.createSender(queue); ObjectMessage message = queueSession.createObjectMessage(); message.setObject(values); queueSender.send(message); </code></pre> <p>and my client is using the following code :</p> <pre><code>class JMSListener implements Runnable, MessageListener { .... public void run() { try { System.out.println("Started JMS Listener"); Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory"); props.put(Context.PROVIDER_URL,"iiop://192.168.38.164:3700"); Context ctx = new InitialContext(props); Queue queue = (Queue) ctx.lookup("sampleQueue"); QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup("sampleFactory"); QueueConnection queueConnection = connectionFactory.createQueueConnection(); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); QueueReceiver queueReceiver = queueSession.createReceiver(queue); queueConnection.start(); queueReceiver.setMessageListener(new JMSListener()); while (true) { if(!Thread.currentThread().equals(runner)) break; try { Thread.sleep(10000); } catch (InterruptedException ex) { Logger.getLogger(JMSListenerRemote.class.getName()).log(Level.SEVERE, null, ex); } } System.out.println("CLOSING!"); // Don't leak queueConnection.close(); } catch (NamingException ex) { Logger.getLogger(Listener.class.getName()).log(Level.SEVERE, null, ex); } catch (JMSException ex) { Logger.getLogger(Listener.class.getName()).log(Level.SEVERE, null, ex); } } public void onMessage(Message message) { System.out.println("Got a message!"); try { ObjectMessage obj = (ObjectMessage) message; HashMap&lt;String, List&lt;String&gt;&gt; values = (HashMap&lt;String, List&lt;String&gt;&gt;) obj.getObject(); for (Entry&lt;String, List&lt;String&gt;&gt; entry : values.entrySet()) { System.out.println("Got key: "+entry.getKey()); } } catch (JMSException ex) { Logger.getLogger(Listener.class.getName()).log(Level.SEVERE, null, ex); } } } </code></pre> <p>It seems to be able to connect correctly because I added some logging to see if the queue and factory were both ok, and they are. And if I change the name of either the queue or the factory I get an error, so that works as expected.</p> <p>What doesn't work though is to actually receive the messages. They seem to be sent out ok, but they never reach the client.</p> <p>Does any one have any ideas as to what might be wrong?</p> <p>Thanks!</p> <p>Edit: Oh, and I'm using GlassFish's built in JMS provider.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload