Results 1 to 5 of 5

Thread: How to use TopicConnectionFactory

  1. #1
    Join Date
    Dec 2005
    Posts
    3

    Unhappy How to use TopicConnectionFactory

    I'm new to Spring JMS and i m using it for a IBM MQ. I was given a jndi object of TopicConnectionFactory and follow the example from ibm-developworkers to config like this:

    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//Spring//DTD Bean//EN" 
        "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <!-- Application Context -->
    <beans>
    	<!-- JNDI Environment Template -->
    	<bean id="jndiTemplate"
    		class="org.springframework.jndi.JndiTemplate">
    		<property name="environment">
    			<props>
    				<prop key="java.naming.factory.initial">
    					com.ibm.mq.jms.context.WMQInitialContextFactory
    				</prop>
    				<prop key="java.naming.provider.url">
    					192.168.1.21:9827/SYSTEM.DEF.SVRCONN
    				</prop>
    				<prop key="java.naming.security.authentication">
    					simple
    				</prop>
    				<prop key="java.naming.security.principal">
    					cn=xx,ou=users,ou=handler,dc=eca,dc=com
    				</prop>
    				<prop key="java.naming.security.credentials">
    					hallo
    				</prop>
    				<prop key="java.naming.referral">throw</prop>
    			</props>
    		</property>
    	</bean>
    
    	<!-- JMS Queue Connection Factory -->
    	<bean id="internalJmsQueueConnectionFactory"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate">
    			<ref bean="jndiTemplate" />
    		</property>
    		<property name="jndiName">
    			<value>TCF.COMMON</value>
    		</property>
    	</bean>
    	
    	<!-- Spring JMS Queue Connection Factory -->
    	<bean id="jmsQueueConnectionFactory"
    		class="org.springframework.jms.connection.SingleConnectionFactory">
    		<property name="targetConnectionFactory">
    			<ref bean="internalJmsQueueConnectionFactory" />
    		</property>
    	</bean>
    
    	<!-- JMS Destination Resolver -->
    	<bean id="jmsDestinationResolver"
    		class="org.springframework.jms.support.destination.JndiDestinationResolver">
    		<property name="jndiTemplate">
    			<ref bean="jndiTemplate" />
    		</property>
    		<property name="cache">
    			<value>true</value>
    		</property>
    	</bean>
    
    	<!-- JMS Queue Template -->
    	<bean id="jmsQueueTemplate"
    		class="org.springframework.jms.core.JmsTemplate">
    		<property name="connectionFactory">
    			<ref bean="internalJmsQueueConnectionFactory" />
    		</property>
    		<!-- for topic is true -->
    		<property name="pubSubDomain">
    			<value>true</value>
    		</property>
    		<property name="destinationResolver">
    			<ref bean="jmsDestinationResolver" />
    		</property>
    		<property name="defaultDestinationName" value="topic_core" />
    		<property name="receiveTimeout">
    			<value>20000</value>
    		</property>
    	</bean>
    
    
    	<bean id="jmsSender" class="JMSSender">
    		<property name="jmsTemplate">
    			<ref bean="jmsQueueTemplate" />
    		</property>
    
    	</bean>
    
    	<bean id="jmsReceiver" class="JMSReceiver">
    		<property name="jmsTemplate">
    			<ref bean="jmsQueueTemplate" />
    		</property>
    	</bean>
    </beans>
    after configed, in my JMSReceiver, i use JMSTemplate in this way:
    HTML Code:
    public void sendMessage(final String text){
    		jmsTemplate.send(new MessageCreator(){
    			public Message createMessage(Session session) throws JMSException {
    				return session.createTextMessage(text);
    			}});
    }
    and it throws a Error:

    java.lang.AbstractMethodError: com.ibm.mq.jms.MQTopicConnectionFactory.createConn ection()Ljavax/jms/Connection;

    i dont know if the AbstractMethodError is the default behavior of TopicConnectionFactory,or just for MQTopicConnectionFactory?
    And could someone give me some advise of how to config a TopicConnectionFactory by Spring JMS? Thanks so much~

  2. #2
    Join Date
    Aug 2004
    Location
    London
    Posts
    164

    Default

    This is a common JMS gotcha...

    http://activemq.org/java.lang.NoSuchMethodError

    It could be due to you not having JMS 1.1 on your classpath. Try using JmsTemplate102 instead
    James Strachan
    ------------------
    Open Source Integration
    Iona

  3. #3
    Join Date
    Dec 2005
    Posts
    3

    Default

    it doesnt effect....... i use the jms.jar from spring 2.0 m1,it should be a
    * j2ee/jms.jar
    - Java Message Service API 1.1 (java.sun.com/products/jms)

    and jar from IBM MQ,also from eclipse to view ConnectionFactory,i saw the method of createConnection(). So it shouldnt be a problem of NoSuchMethod. I guess if it is the MQTopicConnectionFactory, itself will throw a AbstractMethodError when we call createConnection() and will work fine when we call createTopicConnection()

    but i'm not sure about that and got no javadoc for MQTopicConnectionFactory.......

  4. #4
    Join Date
    Aug 2004
    Location
    London
    Posts
    164

    Default

    Are you sure that the MQ jar you have does implement JMS 1.1?
    James Strachan
    ------------------
    Open Source Integration
    Iona

  5. #5
    Join Date
    Dec 2005
    Posts
    3

    Default

    maybe u r right,i will consult out MQ admin in a day or two,and first make out the JMS version MQ implemented.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •