[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
That is not correct. It is an *anti pattern* to create a new session/consumer/producer each time you say, send a message. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255710#4255710 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255710 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
I'm going to wite a wiki page on this. This question must have come up about 10 times and I'm getting tired of answering it ;) View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255717#4255717 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255717 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
That's great. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255731#4255731 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255731 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
Is there connection pooling built in, or is it something I'd have to create myself? I'm looking forward to the wiki. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255738#4255738 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255738 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
anonymous wrote : I've looked around at many tutorials, but they all show the simplistic approach of creating a new connection and session each time. I know of one example that doesn't do this - it creates the connection, session and producer up front and uses that one producer to send an arbitrary number of messages. When it is done, it closes everything. (I hope that is correct, otherwise I will fix it right away.) View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255786#4255786 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255786 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
I've tried something like that, and I'm not sure whether it's a bug or not, but it doesn't seem to work well when the source queue or source queue's jboss instance goes away and comes back (eg during a restart). We're working on a small test case to see if we can reproduce in a simple way. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255787#4255787 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255787 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
I've written a wiki article on this subject, on the HornetQ wiki: http://www.jboss.org/community/wiki/ShouldIcacheJMSconnectionsandJMSsessions View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255793#4255793 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255793 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
Cheers. I'm working with Bob on this issue, and we've found something when keeping open connections, sessions, consumers in our receiver. Below is the code for our sender and our receiver. The receiver continues to check the JMS queue when the queue is stopped and started, and also when the JBoss server is shutdown and restarted. On a queue stop/start, the receiver continues to act as if it's actually trying to get messages. It does not error. When the queue comes back up, the receiver will receive any new messages that arrive after the restart. On a JBoss restart, the receiver does pretty much the same, with no notification of the loss of connectivity, and upon restart, the receiver does NOT receive any new messages that arrive after the JBoss restart. Any ideas on how we can make the receiver realize the server is down so it can handle reconnecting? Sender code: | package com.valpak.renderingservice.indesign.unittests; | | import java.util.Properties; | | import javax.jms.DeliveryMode; | import javax.jms.JMSException; | import javax.jms.ObjectMessage; | import javax.jms.Queue; | import javax.jms.QueueConnection; | import javax.jms.QueueConnectionFactory; | import javax.jms.QueueReceiver; | import javax.jms.QueueSender; | import javax.jms.QueueSession; | import javax.naming.Context; | import javax.naming.InitialContext; | import javax.naming.NamingException; | | import org.apache.log4j.Logger; | | public class JMSSender { | private static Logger log = Logger.getLogger(JMSReceiver.class); | private String jmsServer = jms queue server URL; | private String jmsQueue = queue name; | | public static void main(String[] args) { | JMSSender jmss = new JMSSender(); | try { | while (true) { | log.debug(Sending a message); | jmss.sendMessage(); | Thread.sleep(1); | } | } catch (InterruptedException e) { | e.printStackTrace(); | } | | } | | private void sendMessage() { | InitialContext ctx = null; | QueueConnection conn = null; | QueueConnectionFactory tcf = null; | Queue queue = null; | QueueSession session = null; | QueueSender sender = null; | QueueReceiver receiver = null; | Properties properties = new Properties(); | int replyWaitMS = 3000; | ObjectMessage message = null; | | try { | properties.put(Context.INITIAL_CONTEXT_FACTORY, org.jnp.interfaces.NamingContextFactory); | properties.put(Context.URL_PKG_PREFIXES, org.jnp.interfaces); | properties.put(Context.PROVIDER_URL, jmsServer); | ctx = new InitialContext(properties); | tcf = (QueueConnectionFactory) ctx.lookup(ConnectionFactory); | conn = tcf.createQueueConnection(); | queue = (Queue) ctx.lookup(jmsQueue); | conn.start(); | session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); | sender = session.createSender(queue); | sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT); | String messageBody = You're an idiot!; | message = session.createObjectMessage(messageBody); | Queue tempQueue = session.createTemporaryQueue(); | if (tempQueue != null) { | message.setJMSReplyTo(tempQueue); | sender.setTimeToLive(replyWaitMS * 20); | } else { | sender.setTimeToLive(60 * 60 * 1000); // 60 minutes | } | sender.send(message); | | if (tempQueue != null) { | receiver = session.createReceiver(tempQueue); | Object responseMessage = receiver.receive(replyWaitMS); | if (responseMessage != null) { | ObjectMessage response = (ObjectMessage) responseMessage; | Object responseObject = response.getObject(); | if (responseObject instanceof String) { | log.debug(responseObject); | } | } | } | } catch (NamingException e) { | e.printStackTrace(); | } catch (JMSException e) { |
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
This thread pretty much what I was asking. Unfortunately there were no answers: http://www.jboss.org/index.html?module=bbop=viewtopicp=3890876#3890876 View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255621#4255621 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255621 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Messaging Users] - Re: JMS connection/session handling
Connection pooling is preferred. Session should not be pooled. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=4255633#4255633 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=4255633 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user