0 Replies Latest reply on Mar 29, 2006 1:49 AM by xiqual

    Can't proxy JMS Queues with org.springframework.jndi.JndiObj

    xiqual

      I'm using JBoss 4.0.3SP1 and Spring Framework 1.2.7.
      Proxying of mq destinations is impossible because of lack of Interface for SpyDestination.class

      Even proxying with CGLib won't work because SpyDestination.class has no public constructor.

      Following configuration:

      <bean id="deadLetterQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="queue/DLQ" />
      <property name="cache" value="false" />
      <property name="proxyInterface" value="javax.jms.Queue" />
      </bean>


      produces output:

      org.springframework.jms.InvalidDestinationException: Destination is not an instance of SpyDestination QUEUE.DLQ; nested exception is javax.jms.InvalidDestinationException: Destination is not an instance of SpyDestination QUEUE.DLQ; nested exception is javax.jms.InvalidDestinationException: Destination is not an instance of SpyDestination QUEUE.DLQ
      javax.jms.InvalidDestinationException: Destination is not an instance of SpyDestination QUEUE.DLQ
      at org.jboss.mq.SpyMessageProducer.send(SpyMessageProducer.java:225)
      at org.jboss.mq.SpyMessageProducer.send(SpyMessageProducer.java:212)
      at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:519)
      at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:504)
      at org.springframework.jms.core.JmsTemplate$2.doInJms(JmsTemplate.java:479)
      at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:432)
      at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:477)
      at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:543)
      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      changing proxyInterface to: javax.jms.Destination
      <bean id="responseQueue" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="false">
      <property name="jndiName" value="queue/konektor_out" />
      <property name="cache" value="false" />
      <property name="proxyInterface" value="javax.jms.Destination" />
      </bean>


      produces following output:

      java.lang.ClassCastException: $Proxy1
      at org.jboss.mq.SpySession.createProducer(SpySession.java:657)
      at org.springframework.jms.core.JmsTemplate.doCreateProducer(JmsTemplate.java:807)
      at org.springframework.jms.core.JmsTemplate.createProducer(JmsTemplate.java:788)
      at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:498)
      at org.springframework.jms.core.JmsTemplate$2.doInJms(JmsTemplate.java:479)
      at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:432)
      at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:477)
      at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:543)

      can anyone tell is it possible to change behaviour of this code:

      SpyMessageProducer.class

      if (destination == null || (destination instanceof SpyDestination) == false)
       throw new InvalidDestinationException("Destination is not an instance of SpyDestination " + destination);


      if SpyDestination was an interface in the code above, everything would be fine.