Netty HTTP not allowing bigger messages
gentilim Jul 23, 2010 3:12 PMI'm using HornetQ 2.1.1 Final and have a server/client messaging system. I am trying to configure the communication to be routed through HTTP, but found that messages are not being received by the client (maybe not being sent by the server?). It appears to work when the message data is a smaller amount, but once it gets to a bigger size, it breaks down. The size of the bigger messages is under the large message size of 100KiB. With my setup and sample, it all works when http-enabled is false, but once that is set to true, the client stops getting messages. I get the same results with and without using the HTTP tunneling servlet. Is there a setting I missed perhaps? Perhaps an issue with how http is used? Any insight would be appreciated, thank you.
Here is the netty configs:
<!-- Connectors --> <connectors> <connector name="netty"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class> <param key="http-enabled" value="true"/> <param key="host" value="${jboss.bind.address:localhost}"/> <param key="port" value="${hornetq.remoting.netty.port:28080}"/> </connector> <connector name="in-vm"> <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class> <param key="server-id" value="${hornetq.server-id:0}"/> </connector> </connectors> <!-- Acceptors --> <acceptors> <acceptor name="in-vm"> <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class> <param key="server-id" value="0"/> </acceptor> <acceptor name="netty-acceptor"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> <param key="http-enabled" value="true"/> <param key="port" value="28080"/> </acceptor> </acceptors>
Connection factory:
<connection-factory name="ConnectionFactory"> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="/ServerConnectionFactory"/> </entries> </connection-factory>
Client test code:
//create server connection Map<String, Object> props = new HashMap<String, Object>(); props.put("host", "localhost"); props.put("port", 28080); props.put("http-enabled", true); ClientSessionFactory factory = HornetQClient.createClientSessionFactory(new TransportConfiguration(NettyConnectorFactory.class.getName(), props, "netty")); ClientSession clientSession = null; try { //get session clientSession = factory.createSession(true, true, true, true); clientSession.start(); //get queue clientSession.createTemporaryQueue("jms.queue.exampleQueue", "jms.queue.exampleQueue"); QueueQuery q = clientSession.queueQuery(SimpleString.toSimpleString("jms.queue.exampleQueue")); if(q.isExists()) { //consume ClientConsumer consumer = clientSession.createConsumer("jms.queue.exampleQueue", false); consumer.setMessageHandler(new MessageHandler(){ @Override public void onMessage(ClientMessage message) { log.info("Message received - " + message.getIntProperty("count")); if(message.getBooleanProperty("end")) { run = false; } } }); //start web service Iss.startQueueExample(); while(run) { //run } consumer.close(); } else { log.error("Cannot find queue"); } } catch (HornetQException e) { log.error(e); } log.info("Done"); try { if(clientSession != null) { clientSession.close(); } } catch (HornetQException e) { // TODO Auto-generated catch block e.printStackTrace(); } factory.close();
Server web service code:
logger.info("Start startQueueExample"); try { //get factory javax.naming.Context initialContext = new InitialContext(); HornetQConnectionFactory cf = (HornetQConnectionFactory) initialContext.lookup("/ServerConnectionFactory"); ClientSessionFactory factory = cf.getCoreFactory(); initialContext.close(); //create session ClientSession session = factory.createSession(true, true, true, true); session.start(); //get queue try { QueueQuery q = session.queueQuery(SimpleString.toSimpleString("jms.queue.exampleQueue")); if(q.isExists() && q.getConsumerCount() > 0) { //produce ClientProducer producer = session.createProducer(q.getAddress()); //create the array to send byte[] data = new byte[8000]; //changing this size alters http results! for(Integer i = 0; i < 100; ++i) { ClientMessage message = session.createMessage(ClientMessage.BYTES_TYPE, false); message.putIntProperty("count", i); message.putBooleanProperty("end", false); message.putBytesProperty("data", data); producer.send(message); logger.info("Sent data - " + i); //delay try { Thread.sleep(500); } catch (InterruptedException e) { logger.error(e); } } ClientMessage message = session.createMessage(ClientMessage.BYTES_TYPE, false); message.putIntProperty("count", -1); message.putBooleanProperty("end", true); producer.send(message); logger.info("Sent end"); producer.close(); } else { logger.info("Cannot find queue"); } } catch (HornetQException e) { logger.error(e); } session.close(); factory.close(); cf.close(); } catch (HornetQException e) { logger.error(e); } catch (NamingException e) { logger.error(e); } try { Thread.sleep(500); } catch (InterruptedException e) { logger.error(e); }
When http-enabled is false, all output is expected; all messages are sent and received. When I change http-enabled to true (and only that change) I get different results. When tested with a the data byte array of size 100, everything worked fine. When tested with a byte array of size 8000, all messages appear to be sent, but the client only received a hand full of the sent messages. At the end of the run, there is a warning in the server console:
WARN [RemotingConnectionImpl] Connection failure has been detected: Did not receive ping from /127.0.0.1:64540. It is likely the client has exited or crashed without closing its connection, or the network between the server and client has failed. The connection will now be closed. [code=3] WARN [ServerSessionImpl] Client connection failed, clearing up resources for session f142328e-9688-11df-b4ba-002219285654 WARN [ServerSessionImpl] Cleared up resources for session f142328e-9688-11df-b4ba-002219285654 WARN [ServerSessionPacketHandler] Client connection failed, clearing up resources for session f142328e-9688-11df-b4ba-002219285654 WARN [ServerSessionPacketHandler] Cleared up resources for session f142328e-9688-11df-b4ba-002219285654
This warning was never seen on successful runs. When tested with a byte array of size 40000 all messages appear to be sent, though an expection can be seen on the server after the first couple of message are sent, and the other warning is seen at the end as well:
Sent data - 0 Sent data - 1 Exception in thread "pool-34-thread-1" java.lang.NullPointerException at org.hornetq.core.remoting.impl.netty.HttpAcceptorHandler$ResponseRunner.run(HttpAcceptorHandler.java:173) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Sent data - 2 Exception in thread "pool-34-thread-2" java.lang.NullPointerException at org.hornetq.core.remoting.impl.netty.HttpAcceptorHandler$ResponseRunner.run(HttpAcceptorHandler.java:173) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Sent data - 3 Sent data - 4 Sent data - 5 Sent data - 6 Sent data - 7 Sent data - 8 Sent data - 9 Sent data - 10
continue to end...
On the client, no messages are received.