Does a queue only support one consumer by default?
mrbeagle Sep 25, 2010 3:30 PMI'm having an issue that I have a process running on one server that's dequeuing from a jms queue in hornet. Everything is working fine, however when trying to fire up another process on a different machine or even localhost it times out in my consumer's receive call.
Is there a setting to enable multiple consumers on a queue? Did I set up my connection factory incorrectly so that it locks the queue to one consumer?
here is my connection factory code:
It times out in receive while there is another consumer dequeuing, the other process has one connection that each thread uses. Each thread has it's own session and consumer. Not sure if it matters but all msgs were enqueued by a php script using stomp.
Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(TransportConstants.PORT_PROP_NAME, 5455);
connectionParams.put(TransportConstants.HOST_PROP_NAME, "grv-cache09");
TransportConfiguration tc = new
TransportConfiguration(NettyConnectorFactory.class.getName(),
connectionParams);
HornetQConnectionFactory factory = HornetQJMSClient.createConnectionFactory(tc);
//factory.setPreAcknowledge(true);
factory.setBlockOnDurableSend(false);
connection = factory.createConnection();
connection.start();
public void testHornet() { //This stuff happens in your main() method (statically) Queue q = HornetQJMSClient.createQueue("contentToCrawl"); Map<String, Object> connectionParams = new HashMap<String, Object>(); connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445); connectionParams.put(TransportConstants.HOST_PROP_NAME, "myserver.myhost"); TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams); ConnectionFactory cf = HornetQJMSClient.createConnectionFactory(tc); //This stuff happens on a per thread basis Connection connection = null; Session session = null; try { connection = cf.createConnection(); session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); MessageConsumer messageConsumer = session.createConsumer(q); connection.start(); TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); // print out message counts getMessageCount(connection); } catch (Exception e) { e.printStackTrace(); } finally { if (producer != null) { try { producer.close(); } catch (Exception e) { e.printStackTrace(); } } if (session != null) { try { session.close(); } catch (Exception e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (Exception e) { e.printStackTrace(); } } } }