Bird
Raised Fist0

This code throws MalformedObjectNameException: ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,extra"); What is the error?

medium📝 Debug Q7 of Q15
Kafka - Monitoring and Operations
This code throws MalformedObjectNameException: ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,extra"); What is the error?
AObjectName string format is invalid due to extra comma
BMissing quotes around ObjectName string
CObjectName class is not imported
DJMX server is not connected
Step-by-Step Solution
Solution:
  1. Step 1: Analyze ObjectName string format

    ObjectName strings must follow key=value pairs separated by commas without trailing commas.
  2. Step 2: Identify extra comma causing format error

    The extra comma or malformed key-value causes MalformedObjectNameException.
  3. Final Answer:

    ObjectName string format is invalid due to extra comma -> Option A
  4. Quick Check:

    Malformed ObjectName = Invalid string format [OK]
Quick Trick: ObjectName strings must be valid key=value pairs [OK]
Common Mistakes:
MISTAKES
  • Ignoring string format rules
  • Assuming missing import causes this exception
  • Blaming server connection for format error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes