Quarkus 与骆驼和 TIBCO EMS

问题描述 投票:0回答:1

我想使用 Apache Camel 和 TIBCO EMS 构建 quarkus 应用程序。但是,当我尝试为 TIBCO EMS 版本 8.4 创建连接工厂时,它似乎与我的 quarkus 版本不兼容。您能否建议与 TIBCO EMS 一起使用的正确 quarkus 版本。 另外,是否可以在这里使用 Quarkus 3.x 版本但基于 javax 的 ConnectionFactory ?如果是这样,那我该怎么办呢?

下面是我的pom.xml文件

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.acme</groupId>
    <artifactId>code-helloworld</artifactId>
    <version>1.0.0-SNAPSHOT</version>


    <properties>
        <compiler-plugin.version>3.11.0</compiler-plugin.version>
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>

        <quarkus.platform.version>3.2.4.Final</quarkus.platform.version>
        <tibco-ems.version>8.4</tibco-ems.version>
        <skipITs>true</skipITs>
        <surefire-plugin.version>3.0.0</surefire-plugin.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-camel-bom</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-direct</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-timer</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-jms</artifactId>
        </dependency>
        <!-- TIBCO EMS -->
        <dependency>
            <groupId>com.tibco.ems</groupId>
            <artifactId>tibjms</artifactId>
            <version>${tibco-ems.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>javax.jms-api</artifactId>
            <version>2.0.1</version>
        </dependency>

        <!-- Apache Camel TIBCO EMS -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jms</artifactId>
        </dependency>
        <!-- RabbitMQ -->
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-spring-rabbitmq</artifactId>
        </dependency>
        <dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>5.12.0</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <version>4.0.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                            <goal>generate-code</goal>
                            <goal>generate-code-tests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <native.image.path>
                                    ${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                <maven.home>${maven.home}</maven.home>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <properties>
                <skipITs>false</skipITs>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
        </profile>
    </profiles>
</project>

以下是我的代码:

package routes;
    
import config.TibcoEmsConfiguration;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import javax.jms.ConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;

import javax.naming.NamingException;

@ApplicationScoped
public class SendMessageToEMS extends RouteBuilder {

    @Inject
    TibcoEmsConfiguration tibcoEmsConfiguration;

    // Produce the ConnectionFactory using the Jakarta annotation
    @Produces
    @ApplicationScoped
    public ConnectionFactory jmsConnectionFactory() throws NamingException {
        return tibcoEmsConfiguration.jmsConnectionFactory();
    }

    @Override
    public void configure() throws Exception {
        // Configure the JMS component using the produced ConnectionFactory
        getContext().addComponent("jms",
                JmsComponent.jmsComponentAutoAcknowledge((jakarta.jms.ConnectionFactory) jmsConnectionFactory()));

        from("jms:queue:myQueue")
                .log("Received message in TIBCO EMS: ${body}")
                .to("rabbitmq://localhost:5672/myExchange?queue=rabbitQueue&autoDelete=false&durable=false");

        from("timer:myTimer?period=5000")
                .setBody(simple("Hello from Quarkus Camel 1"))
                .to("jms:queue:myQueue");
    }
}

在这里,在

getContext.addComponent
:我收到错误,因为 TibjmsConnectionFactory 属于 javax 命名空间,但 quarkus 使用 jakarta 命名空间。 我尝试降级 quarkus 版本,但仍然遇到相同的错误。

java apache-camel quarkus tibco ems
1个回答
0
投票

为什么使用这么旧的TIBCO EMS客户端版本? TIBCO EMS 客户端向下兼容。因此,您可以使用 10.x 客户端与 8.4 服务器通信。 10.x 客户端支持 Jakarta 以及 Quarkus 3.x.

© www.soinside.com 2019 - 2024. All rights reserved.