获取到chunkedMessageRate参数的值

在springboot中如何获取到chunkedMessageRate参数的值

可以通过 admin API 通过里面的 stats 获取状态信息(包含chunkedMessageRate)

控制层代码:
List<? extends PublisherStats> publishers = pulsarAdmin.topics().getStats(“myTopic1”).getPublishers();
for (int i = 0; i < publishers.size(); i++) {
PublisherStats publisherStats = publishers.get(i);
System.out.println(“getProducerName=” + publisherStats.getProducerName() + " getChunkedMessageRate=" + publisherStats.getChunkedMessageRate());
}

执行异常:
2022-09-28 22:28:48.431 ERROR 22504 — [nio-8085-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.apache.pulsar.client.admin.PulsarAdminException: java.lang.IllegalArgumentException: The URI scheme, of the URI pulsar://192.168.3.84:6650/admin/v2/persistent/public/default/myTopic1/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false, must be equal (ignoring case) to ‘http’, ‘https’, ‘ws’, or ‘wss’] with root cause

说是必须以http https ws wss开头,不知道如何解决,感谢。

用 8080 的端口。6650 是用来做数据传输的。

C:\jdk1.8\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:C:\ideaIU-2022.2.win\lib\idea_rt.jar=50886:C:\ideaIU-2022.2.win\bin -Dfile.encoding=UTF-8 -classpath C:\jdk1.8\jre\lib\charsets.jar;C:\jdk1.8\jre\lib\deploy.jar;C:\jdk1.8\jre\lib\ext\access-bridge-64.jar;C:\jdk1.8\jre\lib\ext\cldrdata.jar;C:\jdk1.8\jre\lib\ext\dnsns.jar;C:\jdk1.8\jre\lib\ext\jaccess.jar;C:\jdk1.8\jre\lib\ext\jfxrt.jar;C:\jdk1.8\jre\lib\ext\localedata.jar;C:\jdk1.8\jre\lib\ext\nashorn.jar;C:\jdk1.8\jre\lib\ext\sunec.jar;C:\jdk1.8\jre\lib\ext\sunjce_provider.jar;C:\jdk1.8\jre\lib\ext\sunmscapi.jar;C:\jdk1.8\jre\lib\ext\sunpkcs11.jar;C:\jdk1.8\jre\lib\ext\zipfs.jar;C:\jdk1.8\jre\lib\javaws.jar;C:\jdk1.8\jre\lib\jce.jar;C:\jdk1.8\jre\lib\jfr.jar;C:\jdk1.8\jre\lib\jfxswt.jar;C:\jdk1.8\jre\lib\jsse.jar;C:\jdk1.8\jre\lib\management-agent.jar;C:\jdk1.8\jre\lib\plugin.jar;C:\jdk1.8\jre\lib\resources.jar;C:\jdk1.8\jre\lib\rt.jar;C:\Users\Administrator\Desktop\Pulsar_Java_Client\chunking-consumer\target\classes;C:\mvn_repository\org\springframework\boot\spring-boot-starter-web\2.7.1\spring-boot-starter-web-2.7.1.jar;C:\mvn_repository\org\springframework\boot\spring-boot-starter\2.7.1\spring-boot-starter-2.7.1.jar;C:\mvn_repository\org\springframework\boot\spring-boot\2.7.1\spring-boot-2.7.1.jar;C:\mvn_repository\org\springframework\boot\spring-boot-autoconfigure\2.7.1\spring-boot-autoconfigure-2.7.1.jar;C:\mvn_repository\org\springframework\boot\spring-boot-starter-logging\2.7.1\spring-boot-starter-logging-2.7.1.jar;C:\mvn_repository\ch\qos\logback\logback-classic\1.2.11\logback-classic-1.2.11.jar;C:\mvn_repository\ch\qos\logback\logback-core\1.2.11\logback-core-1.2.11.jar;C:\mvn_repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\mvn_repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\mvn_repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\mvn_repository\org\springframework\spring-core\5.3.21\spring-core-5.3.21.jar;C:\mvn_repository\org\springframework\spring-jcl\5.3.21\spring-jcl-5.3.21.jar;C:\mvn_repository\org\yaml\snakeyaml\1.30\snakeyaml-1.30.jar;C:\mvn_repository\org\springframework\boot\spring-boot-starter-json\2.7.1\spring-boot-starter-json-2.7.1.jar;C:\mvn_repository\com\fasterxml\jackson\core\jackson-databind\2.13.3\jackson-databind-2.13.3.jar;C:\mvn_repository\com\fasterxml\jackson\core\jackson-annotations\2.13.3\jackson-annotations-2.13.3.jar;C:\mvn_repository\com\fasterxml\jackson\core\jackson-core\2.13.3\jackson-core-2.13.3.jar;C:\mvn_repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.3\jackson-datatype-jdk8-2.13.3.jar;C:\mvn_repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.3\jackson-datatype-jsr310-2.13.3.jar;C:\mvn_repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.3\jackson-module-parameter-names-2.13.3.jar;C:\mvn_repository\org\springframework\boot\spring-boot-starter-tomcat\2.7.1\spring-boot-starter-tomcat-2.7.1.jar;C:\mvn_repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.64\tomcat-embed-core-9.0.64.jar;C:\mvn_repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.64\tomcat-embed-el-9.0.64.jar;C:\mvn_repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.64\tomcat-embed-websocket-9.0.64.jar;C:\mvn_repository\org\springframework\spring-web\5.3.21\spring-web-5.3.21.jar;C:\mvn_repository\org\springframework\spring-beans\5.3.21\spring-beans-5.3.21.jar;C:\mvn_repository\org\springframework\spring-webmvc\5.3.21\spring-webmvc-5.3.21.jar;C:\mvn_repository\org\springframework\spring-aop\5.3.21\spring-aop-5.3.21.jar;C:\mvn_repository\org\springframework\spring-context\5.3.21\spring-context-5.3.21.jar;C:\mvn_repository\org\springframework\spring-expression\5.3.21\spring-expression-5.3.21.jar;C:\mvn_repository\org\apache\pulsar\pulsar-client-all\2.10.0\pulsar-client-all-2.10.0.jar;C:\mvn_repository\org\apache\pulsar\pulsar-client-api\2.10.0\pulsar-client-api-2.10.0.jar;C:\mvn_repository\org\apache\pulsar\bouncy-castle-bc\2.10.0\bouncy-castle-bc-2.10.0-pkg.jar;C:\mvn_repository\org\bouncycastle\bcpkix-jdk15on\1.69\bcpkix-jdk15on-1.69.jar;C:\mvn_repository\org\bouncycastle\bcprov-jdk15on\1.69\bcprov-jdk15on-1.69.jar;C:\mvn_repository\org\bouncycastle\bcutil-jdk15on\1.69\bcutil-jdk15on-1.69.jar;C:\mvn_repository\org\bouncycastle\bcprov-ext-jdk15on\1.69\bcprov-ext-jdk15on-1.69.jar;C:\mvn_repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\mvn_repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\mvn_repository\net\jcip\jcip-annotations\1.0\jcip-annotations-1.0.jar;C:\mvn_repository\org\apache\pulsar\pulsar-client-admin-api\2.10.0\pulsar-client-admin-api-2.10.0.jar;C:\mvn_repository\jakarta\ws\rs\jakarta.ws.rs-api\2.1.6\jakarta.ws.rs-api-2.1.6.jar;C:\mvn_repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\mvn_repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\mvn_repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;C:\mvn_repository\com\sun\activation\javax.activation\1.2.0\javax.activation-1.2.0.jar;C:\mvn_repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\mvn_repository\org\apache\pulsar\pulsar-package-core\2.10.0\pulsar-package-core-2.10.0.jar;C:\mvn_repository\com\google\guava\guava\31.0.1-jre\guava-31.0.1-jre.jar;C:\mvn_repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\mvn_repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\mvn_repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\mvn_repository\org\checkerframework\checker-qual\3.12.0\checker-qual-3.12.0.jar;C:\mvn_repository\com\google\errorprone\error_prone_annotations\2.7.1\error_prone_annotations-2.7.1.jar;C:\mvn_repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\mvn_repository\com\google\code\gson\gson\2.9.0\gson-2.9.0.jar;C:\mvn_repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\mvn_repository\com\beust\jcommander\1.78\jcommander-1.78.jar com.ghy.www.Application

. ____ _ __ _ _
/\ / __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ’ / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
’ |
| .__|| ||| |_, | / / / /
=========|
|==============|/=////
:: Spring Boot :: (v2.7.1)

2022-09-29 10:24:54.307 INFO 14024 — [ main] com.ghy.www.Application : Starting Application using Java 1.8.0_321 on DESKTOP-5DJML06 with PID 14024 (C:\Users\Administrator\Desktop\Pulsar_Java_Client\chunking-consumer\target\classes started by Administrator in C:\Users\Administrator\Desktop\Pulsar_Java_Client)
2022-09-29 10:24:54.310 INFO 14024 — [ main] com.ghy.www.Application : No active profile set, falling back to 1 default profile: “default”
2022-09-29 10:24:55.554 INFO 14024 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8086 (http)
2022-09-29 10:24:55.565 INFO 14024 — [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-09-29 10:24:55.566 INFO 14024 — [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.64]
2022-09-29 10:24:55.816 INFO 14024 — [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-09-29 10:24:55.816 INFO 14024 — [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1451 ms
2022-09-29 10:24:57.617 INFO 14024 — [r-client-io-1-1] o.a.pulsar.client.impl.ConnectionPool : [[id: 0xae0da59d, L:/192.168.3.188:51108 - R:/192.168.3.84:8080]] Connected to server
2022-09-29 10:24:57.640 WARN 14024 — [r-client-io-1-1] org.apache.pulsar.client.impl.ClientCnx : [/192.168.3.84:8080] Got exception org.apache.pulsar.shade.io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 5253120: 1213486164 - discarded
at org.apache.pulsar.shade.io.netty.handler.codec.LengthFieldBasedFrameDecoder.fail(LengthFieldBasedFrameDecoder.java:503)
at org.apache.pulsar.shade.io.netty.handler.codec.LengthFieldBasedFrameDecoder.failIfNecessary(LengthFieldBasedFrameDecoder.java:489)
at org.apache.pulsar.shade.io.netty.handler.codec.LengthFieldBasedFrameDecoder.exceededFrameLength(LengthFieldBasedFrameDecoder.java:376)
at org.apache.pulsar.shade.io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:419)
at org.apache.pulsar.shade.io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:332)
at org.apache.pulsar.shade.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
at org.apache.pulsar.shade.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
at org.apache.pulsar.shade.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at org.apache.pulsar.shade.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at org.apache.pulsar.shade.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at org.apache.pulsar.shade.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at org.apache.pulsar.shade.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at org.apache.pulsar.shade.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at org.apache.pulsar.shade.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at org.apache.pulsar.shade.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at org.apache.pulsar.shade.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at org.apache.pulsar.shade.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at org.apache.pulsar.shade.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at org.apache.pulsar.shade.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)

我用8080后启动生产者出现异常了。

这是我的yml配置
spring:
application:
name: chunking-producer-8086
server:
port: 8085

pulsar:
serviceUrl: pulsar://192.168.3.84:8080
myTopic1: myTopic1

不知道怎么回事。

找了异常,没有看懂。我用6650和pulsar通信不建议吗?

找了一下资料:
web 服务的 URL 以及端口 ,默认的端口 是8080
但我用的是spring boot连接pulsar的

Admin API 默认走 http 协议的 8080 端口,使用类似:http://broker-ip:8080 . (不要用 pulsar:// 开头)