Reputation: 4777
I was looking through various examples for Apache Camel Jms connection and was trying to figure out if i can
wire in a QueueConnectionFactory
for a custom Jms provider to my JmsComponent?
So i want to lookup the queue name through jndi
but i have the custom QueueConnectionFactory
to create the connection
and then from that call createQueueSession
.
My sudo code is as follows:
<bean id="customQueueConnectionFactory" class="QueueConnectionFactoryImpl"/>
<bean id="authenticatedConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="customQueueConnectionFactory"/>
<property name="username" value="username"/>
<property name="password" value="password"/>
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="authenticatedConnectionFactory"/>
</bean>
This is failing as its not the right way to wire in a QueueConnectionFactory.
QueueConnectionFactoryImpl.createConnection(Ljava/lang/String;Ljava/lang/String;)Ljavax/jms/Connection;
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:175)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:150)
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:405)
at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:373)
at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:767)
at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:280)
at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:265)
at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:568)
at org.apache.camel.component.jms.JmsConsumer.startListenerContainer(JmsConsumer.java:105)
at org.apache.camel.component.jms.JmsConsumer.prepareAndStartListenerContainer(JmsConsumer.java:171)
at org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:155)
Any hints? I am using Spring version 3.2.4 & Apache Camel version 2.12.2
Upvotes: 1
Views: 1535
Reputation: 55525
camel-jms uses Spring JMS, so you just wireup this the Spring way. At first glance your spring < bean > looks okay.
Remember to use "jms" as the component name in Camel, as that is the id you gave the component.
Upvotes: 1