小编moh*_*oha的帖子

ActiveMQ:Openwire vs AMQP vs Stomp

ActiveMQ是一个消息代理,支持许多不同的协议,如Openwire,AMQP和Stomp.要知道这真令人困惑:

  • 使用Openwire和AMQP作为基础协议在项目中发送和接收消息有什么区别?
  • 任何这些协议相互之间的优点和缺点是什么?
  • 这可以同时在同一台机器上使用吗?
  • 是否有可能使用Stomp从浏览器发送消息并使用其他两个协议在服务器中接收该消息?

java activemq-classic stomp amqp

15
推荐指数
1
解决办法
6729
查看次数

获取List中元素的类型,其中List是java中方法的返回类型

我使用反射获取包中的每个方法,然后根据每个方法的返回类型,我想做一些操作。但不幸的是我在收藏方面遇到了问题。当我找到一个返回像 List 这样的集合的方法时,我找不到方法来了解 List 元素的类型。我使用下面的代码来获取我的方法的返回类型。

if (method.getReturnType().equals(List.class)){
    statement;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码确实工作得很好,并获取了返回列表的每个方法,但它只是返回 java.util.List 作为返回类型,我找不到一种方法来了解该列表中元素的类型。例如,如果我有这样的方法:

public List<CmsCustomerModel> getCustomerModel(){
    statement;
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何获取 CmsCustomerModel 类作为返回列表的元素类型。我想知道是否有人帮我找到这个。请指导我。

java reflection collections

4
推荐指数
1
解决办法
3225
查看次数

在同一台机器上同时运行 ActiveMQ 和 RabbitMQ 时 AMQP 协议版本不匹配

我一直在尝试开发一个同时使用 activeMQ 和 rabbitMQ 的项目。我在 pom.xml 中添加的依赖项如下:

    <dependency>
        <groupId>org.springframework.amqp</groupId>
        <artifactId>spring-rabbit</artifactId>
        <version>1.4.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>4.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-broker</artifactId>
        <version>5.13.0</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

另外,我同时运行apache-activemq-5.13.0rabbitmq-server-3.5.6。但不幸的是,我遇到了一个与 AMQP 相关的错误,如下所示:

java.io.IOException
    at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
    at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:350)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:648)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:678)
    at org.hafiz.framework.common.rabbit.filter.ReceiveRabbitMessageFilter.init(ReceiveRabbitMessageFilter.java:33)
    at org.hafiz.common.filter.PrmTarrifTypeMessageFilter.init(PrmTarrifTypeMessageFilter.java:21)

    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)

    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1948)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection …
Run Code Online (Sandbox Code Playgroud)

java spring activemq-classic amqp rabbitmq

3
推荐指数
1
解决办法
4755
查看次数

Spring Amqp在springframework RetryCallback类中具有NoClassDefFoundError

我一直在从事一个分布式Web项目,我想在其中使用RabbitMq来利用Spring amqp。我在项目中使用springFramework版本4.1.6。为此,我将以下依赖项添加到了文件pom.xml中。

<dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>3.5.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-amqp</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

另外,我在下面的web.xml中放置了RabbitMQ配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/rabbit
        http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="org.myTest" />

    <rabbit:connection-factory id="connectionFactory"
        host="localhost" port="5672" username="guest" password="guest" />

    <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />

    <rabbit:admin connection-factory="connectionFactory" />

    <rabbit:queue name="myQueue" />

    <rabbit:topic-exchange name="myExchange">
        <rabbit:bindings>
            <rabbit:binding queue="myQueue" pattern="myQueue"></rabbit:binding>
        </rabbit:bindings>
    </rabbit:topic-exchange>

    <bean id="rabbitListenerContainerFactory"
        class="org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory">
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="concurrentConsumers" value="3" />
        <property name="maxConcurrentConsumers" …
Run Code Online (Sandbox Code Playgroud)

java rabbitmq spring-rabbit spring-amqp

1
推荐指数
1
解决办法
8025
查看次数