Hi there,
I'm banging my head on this problem for a while now so thought I better ask this forum.
I'm using JBoss AS 7.1.1 with full-ha configuration. I want to use HornetQ as my messaging server. I'm developing in Spring 3.1.2.
I am experimenting with the testQueue as defined in standalone/configuration/standalone-full-ha.xml:
My Spring configuration is as follows:Code:<jms-queue name="testQueue"> <entry name="queue/test"/> <entry name="java:jboss/exported/jms/queue/test"/> </jms-queue>
And in my code (Controller) I'm using jmsTemplate as follows:Code:<bean name="qConnectionFactory" class="org.hornetq.jms.client.HornetQXAConnectionFactory"> <constructor-arg name="ha" value="true" /> <constructor-arg> <bean name="transportConfiguration" class="org.hornetq.api.core.TransportConfiguration"> <constructor-arg value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"/> <constructor-arg> <map key-type="java.lang.String" value-type="java.lang.Object"> <entry key="host" value="localhost" /> <entry key="port" value="5445" /> </map> </constructor-arg> </bean> </constructor-arg> </bean> <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial">org.jboss.as.naming.InitialContextFactory</prop> <prop key="java.naming.provider.url">remote://localhost:4447</prop> <prop key="java.naming.security.principal">user</prop> <prop key="java.naming.security.credentials">password</prop> </props> </property> </bean> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref bean="qConnectionFactory"/> </property> <property name="destinationResolver"> <bean class="org.springframework.jms.support.destination.JndiDestinationResolver"/> </property> </bean> <!-- A destination in JBoss/HornetQ --> <bean id="testQueue" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:jboss/exported/jms/queue/test</value> </property> <property name="jndiTemplate" ref="jndiTemplate"/> </bean>
When I try to send the message, I get the following JmsException:Code:@Autowired private JmsTemplate jmsTemplate; @Autowired private Destination testQueue; jmsTemplate.send(testQueue, new MessageCreator() { public Message createMessage(Session session) throws JMSException { Message message = session.createMessage(); return message; } });
org.springframework.jms.InvalidDestinationExceptio n: Not a HornetQ Destination:HornetQQueue[testQueue]; nested exception is javax.jms.InvalidDestinationException: Not a HornetQ Destination:HornetQQueue[testQueue]
This is thrown from HornetQSession at:
This method is expecting a HornetQDestination while Spring autowires a HornetQQueue.Code:public MessageProducer createProducer(final Destination destination) throws JMSException { if (destination != null && !(destination instanceof HornetQDestination)) { throw new InvalidDestinationException("Not a HornetQ Destination:" + destination); } ...
1) I'm not sure how Spring knows to autowire a HornetQQueue (although it should be a HornetQDestination, it is close!)
2) It should autowire a HornetQDestination, right?
Has anyone worked around this?
Many thanks,
Nes


Reply With Quote
