How to create a camel-k source kamelet to a weblogic queue

143 Views Asked by At

I am trying to write a bridge between tow weblogic queues using camel-k on ocp, I have issues to define the queue connection , du to the camel DSl.

**Here is the yaml code **:



apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: jms-weblogic-mq-source
  annotations:
    camel.apache.org/kamelet.group: "JMS"
  labels:
    camel.apache.org/kamelet.type: "source"
    camel.apache.org/requires.runtime: camel-k
spec:
  definition:
    name: jms-weblogic-mq-source
    properties:
      queueName:
        type: string
        title: Queue Name
        description: Name of the JMS queue to consume messages from
        required: true
      transacted:
        type: boolean
        title: Transacted
        description: Whether to use transacted sessions for consuming messages
        default: false
      acknowledgementModeName:
        type: string
        title: Acknowledgement Mode
        description: JMS acknowledgement mode to use when consuming messages
        default: AUTO_ACKNOWLEDGE
        enum:
          - AUTO_ACKNOWLEDGE
          - CLIENT_ACKNOWLEDGE
          - DUPS_OK_ACKNOWLEDGE
          - SESSION_TRANSACTED
      jndiInitialContextFactory:
        type: string
        title: JNDI Initial Context Factory
        description: JNDI Initial Context Factory for the WebLogic JMS server
        required: true
      jndiProviderUrl:
        type: string
        title: JNDI Provider URL
        description: JNDI Provider URL for the WebLogic JMS server
        required: true
      jndiConnectionFactoryName:
        type: string
        title: JNDI Connection Factory Name
        description: JNDI name of the connection factory to use
        required: true
      userName:
        type: string
        title: User Name
        description: User name to use when connecting to the WebLogic JMS server
        required: true
      password:
        type: string
        title: Password
        description: Password to use when connecting to the WebLogic JMS server
        required: true
  dependencies:
  - "camel:jms"
  - "camel:kamelet"
  - "mvn:com.oracle.weblogic:wlthint3client:12.1.3"
  - "mvn:org.springframework:spring-context:5.3.23"

  template:
    beans:
      - name: jndiTemplate
        type: "#class:org.springframework.jndi.JndiTemplate"
        properties:
          environment:
            - key: java.naming.factory.initial
              value: '{{jndiInitialContextFactory}}'
            - key: java.naming.provider.url
              value: '{{jndiProviderUrl}}'
            - key: java.naming.security.principal
              value: '{{userName}}'
            - key: ava.naming.security.credentials
              value: '{{password}}'
      - name: jndiObjectFactoryBean
        type: "#class:org.springframework.jndi.JndiObjectFactoryBean"
        properties:
            jndiTemplate: '#bean:jndiTemplate'
            jndiName: '{{jndiConnectionFactoryName}}'
            proxyInterface: javax.jms.ConnectionFactory
    from:
      uri: "jms:queue:{{queueName}}"
      parameters:
        connectionFactory: '#bean:jndiObjectFactoryBean#getObject'
        transacted: "{{transacted}}"
        deliveryMode: "{{acknowledgementModeName}}"
      steps:
      - to:
          uri: "kamelet:sink"

And i am having this error:

[2023-03-15 14:00:37,449
ERROR
org.apa.cam.qua.mai.CamelMainRuntime
Failed to start application: java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')
[1]     at org.apache.camel.dsl.yaml.deserializers.BeanFactoryDefinitionDeserializer.lambda$setProperty$0(BeanFactoryDefinitionDeserializer.java:61)
[1]     at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
[1]     at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1764)
[1]     at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[1]     at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[1]     at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
[1]     at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[1]     at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
[1]     at org.apache.camel.dsl.yaml.deserializers.BeanFactoryDefinitionDeserializer.setProperty(BeanFactoryDefinitionDeserializer.java:62)
1

There are 1 best solutions below

0
Squake On

I think the problem is in the definition of one of the beans properties. Try with:

template:
  beans:
    - name: jndiTemplate
      type: "#class:org.springframework.jndi.JndiTemplate"
      property:
        - key: java.naming.factory.initial
          value: '{{jndiInitialContextFactory}}'
        - key: java.naming.provider.url
          value: '{{jndiProviderUrl}}'
        - key: java.naming.security.principal
          value: '{{userName}}'
        - key: ava.naming.security.credentials
          value: '{{password}}'

I've tested with latest version of Camel K and this seems to work.