See http://activemq.apache.org/how-do-i-use-jms-efficiently.html
On 09/04/2008, James Strachan <[EMAIL PROTECTED]> wrote: > You are not using your J2EE providers JMS proxy to cache things; you > are using vanilla JMS. > > So try using the PooledConnectionFactory from ActiveMQ instead. > > > > On 09/04/2008, paoletto <[EMAIL PROTECTED]> wrote: > > > > i wrote the following Stateless Session Bean, and ran in a j2ee > application > > on jbossAS. > > > > With the following implementation i have the problem that, if for example > i > > put the send in a for > > to send 1000 messages (invocations) in a row, after about 200-250 the > sender > > start to slow down and at > > about 300th message, it start to take 3-4 minute to send 1 single message. > > then i have to stop the AS, > > cause JVM goes to 100% load and the for cycle does not end. > > > > i dont know what i did wrong here.. > > But what i can say is that if every time i also create a new > > ActiveMQConnectionFactory, everything > > slowes down quite much, but it does not suffer from the problem before > (that > > means, poor but constant performances) > > > > any clue? > > > > > > > > > > > > > > @Stateless > > public class JmsFrontendBean implements > JmsFrontendRemote,JmsFrontendLocal > > { > > public static final String RemoteJNDIName = > > JmsFrontendBean.class.getSimpleName() + "/remote"; > > public static final String LocalJNDIName = > > JmsFrontendBean.class.getSimpleName() + "/local"; > > > > // private Context ctx = null; > > ActiveMQConnectionFactory connectionFactory = null; > > > > @PostConstruct > > private void postConstruct() { > > try { > > connectionFactory = new > ActiveMQConnectionFactory("vm://localhost"); > > connectionFactory.setOptimizeAcknowledge(true); > > connectionFactory.setUseAsyncSend(true); > > connectionFactory.setAlwaysSessionAsync(true); > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > > > @WebMethod > > public void sendInvocation(InvocationRequest ir) { > > > > try { > > // Create a Connection > > Connection connection = connectionFactory.createConnection(); > > connection.start(); > > > > // Create a Session > > Session session = connection.createSession(false, > > Session.AUTO_ACKNOWLEDGE); > > > > // Create the destination (Topic or Queue) > > Destination destination = > > session.createQueue("queue."+ir.getQdest()); > > > > // Create a MessageProducer from the Session to the Topic or > > Queue > > MessageProducer producer = session.createProducer(destination); > > //producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); > > producer.setDeliveryMode(DeliveryMode.PERSISTENT); > > > > // Create a messages > > JmsPayload payload = new JmsPayload(); > > > > String dataString = ir.getService() + "/" + ir.getMethod() + > "?" > > + ir.getParam(); > > payload.setDataString(dataString); > > > > if (ir.getFileAttachments() != null) { > > for (int i = 0; i < ir.getFileAttachments().length; i++) { > > String url = ir.getFileAttachments()[i]; > > Attachment a = getAttachment(url); > > if (a != null) payload.addAttachment(a); > > } > > } > > > > ObjectMessage objmessage = > session.createObjectMessage(payload); > > > > // Tell the producer to send the message > > System.out.println("Sending message to: " + ir.getQdest() + " > > with values: "+dataString); > > producer.send(objmessage); > > > > // Clean up > > producer.close(); > > session.close(); > > connection.stop(); > > connection.close(); > > } catch (Exception e) { > > System.out.println("Caught: " + e); > > e.printStackTrace(); > > } > > } > > > > -- > > View this message in context: > http://www.nabble.com/Sending-message-from-EJB3%3A-poor-performances-after-a-while-tp16583813s2354p16583813.html > > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > > > > > > > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://open.iona.com > -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com