Search code examples
spring-bootapache-camelibm-mq

'CachingConnectionFactory(jakarta.jms.ConnectionFactory)' cannot be applied to '(com.ibm.mq.jms.MQConnectionFactory)'


In my project, I am using apache camel + ibm mq + spring boot for messaging. I am getting a compile time err which I am not able to resolve.

com.ibm.mq.jms.MQConnectionFactory mqQueueConnectionFactoy = new MQQueueConnectionFactory();
// set all the properties to above mqQueueConnectionFactoy such as queue manager etc.
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(mqQueueConnectionFactoy);

Now on the second line I am getting this err:

Now on the second line I am getting this err:
'CachingConnectionFactory(jakarta.jms.ConnectionFactory)' in 'org.springframework.jms.connection.CachingConnectionFactory' cannot be applied to '(com.ibm.mq.jms.MQConnectionFactory)'

I have googled a lot but not able to find any such example. Any help would be appreciate. My build.gradle has below dependencies.

// Camel
    implementation 'org.apache.camel.springboot:camel-spring-boot-starter:4.0.0-M1'
    implementation('org.apache.camel.springboot:camel-servlet-starter:4.0.0-M1')
    implementation('org.apache.camel.springboot:camel-jaxb-starter:4.0.0-M1')
    implementation("org.apache.camel:camel-jms:4.0.0-M1")
    implementation("org.apache.camel:camel-core:4.0.0-M1")

    // IBM MQ
    implementation("javax.jms:javax.jms-api:2.0.1")
    implementation("com.ibm.mq:com.ibm.mq.allclient:9.1.0.5")
    implementation("com.ibm.ims:udb:15.1.31")
    implementation("javax.xml.bind:jaxb-api:2.4.0-b180830.0359")

Solution

  • You will need to replace your com.ibm.mq.allclient dependency with com.ibm.mq.jakarta.client and replace javax.jms-api:2.0.1 with jakarta.jms-api

    Ala

    https://www.ibm.com/docs/en/ibm-mq/9.3?topic=umcjm-obtaining-mq-classes-jms-mq-classes-jakarta-messaging-separately

    See https://mvnrepository.com/artifact/com.ibm.mq/com.ibm.mq.jakarta.client and https://mvnrepository.com/artifact/jakarta.jms/jakarta.jms-api for latest versions.