# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: jms-apache-activemq-sink
  annotations:
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,[encoded data, 26696 characters]"
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/catalog.version: "3.21.0"
    camel.apache.org/kamelet.group: "JMS"
    camel.apache.org/kamelet.namespace: "Messaging"
  labels:
    camel.apache.org/kamelet.type: "sink"
    camel.apache.org/requires.runtime: camel-k
spec:
  definition:
    title: "JMS - Apache ActiveMQ Classic Sink"
    description: "A Kamelet that can produce events to an Apache ActiveMQ Classic message broker using JMS"
    required:
      - destinationName
      - brokerURL
    type: object
    properties:
      destinationType:
        title: "Destination Type"
        description: "The JMS destination type (i.e.: queue or topic)"
        type: string
        default: queue
      destinationName:
        title: "Destination Name"
        description: "The JMS destination name"
        type: string
        example: person
      brokerURL:
        title: "Broker URL"
        description: "The JMS URL"
        type: string
        example: "tcp://my-host:61616"
      password:
        default: admin
        description: Target AMQ Broker password
        example: password1!
        title: Broker Password
        type: string
        format: password
        x-descriptors:
          - urn:alm:descriptor:com.tectonic.ui:password
          - urn:camel:group:credentials        
      username:
        default: admin
        description: Target AMQ Broker Username
        example: userName
        title: Broker Username
        type: string    
        x-descriptors:
          - urn:camel:group:credentials             
  dependencies:
  - "camel:kamelet"
  - "camel:activemq"
  - "mvn:org.apache.activemq:activemq-http:5.17.3"
  template:
    beans:
      - name: sinkConnectionFactoryBean-local
        type: "#class:org.apache.activemq.ActiveMQConnectionFactory"
        property:
          - key: userName
            value: '{{username}}'
          - key: password
            value: '{{password}}'
          - key: brokerURL
            value: '{{brokerURL}}'
      - name: activemq-sink-local
        type: '#class:org.apache.camel.component.activemq.ActiveMQComponent'      
    from:
      uri: "kamelet:source"
      steps:
      - to:
          uri: "{{activemq-sink-local}}:{{destinationType}}:{{destinationName}}"
          parameters:
            connectionFactory: "#bean:{{sinkConnectionFactoryBean-local}}"