1 16 17 package org.springframework.jms.listener.serversession; 18 19 import javax.jms.Connection ; 20 import javax.jms.ConnectionConsumer ; 21 import javax.jms.Destination ; 22 import javax.jms.JMSException ; 23 import javax.jms.Queue ; 24 import javax.jms.QueueConnection ; 25 import javax.jms.QueueConnectionFactory ; 26 import javax.jms.ServerSessionPool ; 27 import javax.jms.Session ; 28 import javax.jms.Topic ; 29 import javax.jms.TopicConnection ; 30 import javax.jms.TopicConnectionFactory ; 31 32 41 public class ServerSessionMessageListenerContainer102 extends ServerSessionMessageListenerContainer { 42 43 46 protected Connection createConnection() throws JMSException { 47 if (isPubSubDomain()) { 48 return ((TopicConnectionFactory ) getConnectionFactory()).createTopicConnection(); 49 } 50 else { 51 return ((QueueConnectionFactory ) getConnectionFactory()).createQueueConnection(); 52 } 53 } 54 55 58 protected ConnectionConsumer createConsumer(Connection con, Destination destination, ServerSessionPool pool) 59 throws JMSException { 60 61 if (isPubSubDomain()) { 62 if (isSubscriptionDurable()) { 63 return ((TopicConnection ) con).createDurableConnectionConsumer( 64 (Topic ) destination, getDurableSubscriptionName(), getMessageSelector(), pool, getMaxMessagesPerTask()); 65 } 66 else { 67 return ((TopicConnection ) con).createConnectionConsumer( 68 (Topic ) destination, getMessageSelector(), pool, getMaxMessagesPerTask()); 69 } 70 } 71 else { 72 return ((QueueConnection ) con).createConnectionConsumer( 73 (Queue ) destination, getMessageSelector(), pool, getMaxMessagesPerTask()); 74 } 75 } 76 77 80 protected Session createSession(Connection con) throws JMSException { 81 if (isPubSubDomain()) { 82 return ((TopicConnection ) con).createTopicSession(isSessionTransacted(), getSessionAcknowledgeMode()); 83 } 84 else { 85 return ((QueueConnection ) con).createQueueSession(isSessionTransacted(), getSessionAcknowledgeMode()); 86 } 87 } 88 89 94 protected boolean isClientAcknowledge(Session session) throws JMSException { 95 return (getSessionAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE); 96 } 97 98 } 99 | Popular Tags |