当前位置: 首页 > 知识库问答 >
问题:

我在使用gatling amqp插件从gatling连接到rabbit q时遇到问题

高自怡
2023-03-14

我在这里完全被难住了(斯卡拉神秘的神秘性没有帮助:-))

我试图使用Rabbitmq设置gatling测试(即我想把消息推送到一个Rabbit q中,并计算出现在第二个队列中需要多长时间),我使用gatling-amqp-plugin来做这件事,因为gatling本机不支持amqp。

为了让这对我来说更“有趣”,我不使用Scala编写代码,也从未使用过gatling。。。。

所以我参加了“入门”项目gatling sbt插件演示

一旦确定示例computerdatabase负载测试有效,我就向项目中添加了一个新包,并将amqp项目中的示例PublishExample(以及所需的Utils类)放入其中

我有一个本地兔子码头形象运行。。。这是我使用的docker compose:

version: '3'

services:
  rabbi:
    image: rabbitmq:3.6-management
    hostname: "rabbi"
    expose:
      - "5672"
    ports:
      - "15672:15672"
      - "5672:5672"
    environment:
      RABBITMQ_DEFAULT_USER: "USER"
      RABBITMQ_DEFAULT_PASS: "PASS"
      RABBITMQ_DEFAULT_VHOST: "VOST"

然后,我尝试使用这个示例运行gatling

package rabbit

import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import ru.tinkoff.gatling.amqp.Predef._
import Utils._
import ru.tinkoff.gatling.amqp.protocol.AmqpProtocolBuilder

import scala.concurrent.duration._

class PublishExample extends Simulation {

  val amqpConf: AmqpProtocolBuilder = amqp
    .connectionFactory(
      rabbitmq
        .host("localhost")
        .port(5672)
        .username("USER")
        .password("PASS")
        .vhost("VOST")
    )
    .usePersistentDeliveryMode

  val scn: ScenarioBuilder = scenario("AMQP test")
    .feed(idFeeder)
    .exec(
      amqp("publish to exchange").publish
        .directExchange("test_queue", "test_key")
        .textMessage("Hello message - ${id}")
        .messageId("${id}")
        .priority(0)
        .property("testheader", "testvalue")
    )

  setUp(
    scn.inject(rampUsersPerSec(1) to 5 during (60 seconds), constantUsersPerSec(5) during (5 minutes))
  ).protocols(amqpConf)
    .maxDuration(10 minutes)

}

这就是我得到的错误

:
sbt:gatling-sbt-plugin-demo> gatling:test
[info] Compiling 1 Scala source to<project_folder>/gatling-sbt-plugin-demo/target/scala-2.12/test-classes ...
[info] Compiling 1 Scala source to<project_folder>/gatling-sbt-plugin-demo/target/scala-2.12/gatling-classes ...
Simulation rabbit.PublishExample started...
Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-6]: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[GatlingSystem]
java.lang.NoSuchMethodError: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.forceModify(AmqpProtocolMessage.scala:23)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties$3(AmqpProtocolMessage.scala:18)
        at scala.collection.IndexedSeqOptimized.foldLeft(IndexedSeqOptimized.scala:60)
        at scala.collection.IndexedSeqOptimized.foldLeft$(IndexedSeqOptimized.scala:68)
        at scala.collection.mutable.ArrayOps$ofRef.foldLeft(ArrayOps.scala:198)
  | => gat ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties$2(AmqpProtocolMessage.scala:18)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.$anonfun$mergeProperties$1(AmqpProtocolMessage.scala:14)
        at com.softwaremill.quicklens.package$PathModify.using(package.scala:62)
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.mergeProperties(AmqpProtocolMessage.scala:16)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$anonfun$sendRequest$2(AmqpAction.scala:27)
        at io.gatling.commons.validation.Success.map(Validation.scala:45)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$anonfun$sendRequest$1(AmqpAction.scala:27)
        at io.gatling.commons.validation.Success.flatMap(Validation.scala:46)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.sendRequest(AmqpAction.scala:24)
        at io.gatling.core.action.RequestAction.$anonfun$execute$1(Action.scala:100)
        at io.gatling.commons.validation.Success.flatMap(Validation.scala:46)
        at io.gatling.core.action.RequestAction.execute(Action.scala:97)
        at io.gatling.core.action.RequestAction.execute$(Action.scala:96)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.execute(AmqpAction.scala:12)
        at io.gatling.core.action.Action.$bang(Action.scala:38)
        at io.gatling.core.action.Action.$bang$(Action.scala:38)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.io$gatling$core$action$ChainableAction$$super$$bang(AmqpAction.scala:12)
        at io.gatling.core.action.ChainableAction.$bang(Action.scala:63)
        at io.gatling.core.action.ChainableAction.$bang$(Action.scala:61)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.io$gatling$core$action$ExitableAction$$super$$bang(AmqpAction.scala:12)
        at io.gatling.core.action.ExitableAction.$bang(BlockExit.scala:141)
        at io.gatling.core.action.ExitableAction.$bang$(BlockExit.scala:139)
        at ru.tinkoff.gatling.amqp.action.AmqpAction.$bang(AmqpAction.scala:12)
        at io.gatling.core.action.SingletonFeed$$anonfun$receive$1.applyOrElse(SingletonFeed.scala:71)
        at akka.actor.Actor.aroundReceive(Actor.scala:539)
        at akka.actor.Actor.aroundReceive$(Actor.scala:537)
        at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:25)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612)
        at akka.actor.ActorCell.invoke(ActorCell.scala:581)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
        at akka.dispatch.Mailbox.run(Mailbox.scala:229)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
        at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
[info] Simulation(s) execution ended.
[error] Error during tests:
[error]         Running java with options -classpath <my system class path> 
sbt.ForkMain 51328 failed with exit code 255
[error] (Gatling / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 3 s, completed 26-Apr-2020 22:06:37
sbt:gatling-sbt-plugin-demo> 

我到底在这里拧什么?我尝试了主机/vhost/DirectExchange配置的各种更改,但我不知道我做错了什么!!!

还有我运行上述代码时兔子的日志:

rabbi_1  |
rabbi_1  | =INFO REPORT==== 26-Apr-2020::21:12:13 ===
rabbi_1  | accepting AMQP connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672)
rabbi_1  |
rabbi_1  | =INFO REPORT==== 26-Apr-2020::21:12:13 ===
rabbi_1  | connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672): user 'USER' authenticated and granted access to vhost 'VOST'
rabbi_1  |
rabbi_1  | =WARNING REPORT==== 26-Apr-2020::21:12:14 ===
rabbi_1  | closing AMQP connection <0.619.0> (172.20.0.1:56118 -> 172.20.0.2:5672, vhost: 'VOST', user: 'USER'):
rabbi_1  | client unexpectedly closed TCP connection

所以我知道我在和兔子“联系”

共有1个答案

阳文轩
2023-03-14

Stacktrace是不言自明的:

java.lang.NoSuchMethodError: java.lang.reflect.Field.canAccess(Ljava/lang/Object;)Z
        at ru.tinkoff.gatling.amqp.request.AmqpProtocolMessage.forceModify(AmqpProtocolMessage.scala:23)

这个方法是在Java9中引入的,这意味着这个第三方插件需要与Java9一起运行(与官方的Gatling组件相反,从3.3.1开始就需要Java8)。

 类似资料:
  • 当我运行此命令时 uvicorn应用程序。主:应用程序--主机0.0.0.0--端口8000--重新加载 我得到这个错误 SQL炼金术。exc.OperationalError:(pymysql.err.OperationalError)(2003,“无法连接到“0.0.0.0”上的MySQL服务器([WinError 10049]请求的地址在其上下文中无效)”)(此错误的背景信息位于:http:

  • 我想把这个项目放到github上。我创建了一个存储库。复制的代码被粘贴到由代码连接的终端中。当我激活设备时,它会给我一个错误。错误是找不到存储库(存储库名称与我要连接的存储库的名称完全不同)

  • 我使用的是JAX-RS注解,但我遇到了@BeanParam的问题。我用的是Wildfly-Swarm和maven。以下几行是我错误的一部分:

  • 编辑:我刚刚意识到,即使是一个带有应用程序条的简单屏幕,也会发生这种情况 错误:任务“:app:checkdebugaarmadata”的执行失败 无法解析配置“:app:debugRuntimeClasspath”的所有文件。无法解析com。谷歌。firebase:firebase firestore:22.1.2。所需人员:项目:应用程序 无法解析com。谷歌。firebase:firebas

  • 我在Spring Data JPA+Hibernate中使用Javers。当我使用curdrepository.save(Collection)时,Javers API会逐一审核集合中的每个对象,这会导致整个插入过程的延迟。 在集成Javers之前,处理100行需要30秒,集成Javers之后需要80秒。

  • 我有一个使用phonegap 3.1的项目,效果很好。 我添加了cordova文件插件,如下所示: 然后 运行良好。 我在xcode中打开项目,它无法编译并出现错误: 这是毫无意义的,所以我进一步研究了这个CDVFile。h和CDV文件。m在我的xcode项目的插件目录中以红色突出显示,单击它们不会显示其代码。我的其他插件工作正常。 我试过产品- 有人知道我还能试试什么吗?