@Smita Mohapatra Thanks for reaching out. As per the Java API reference document I can see below Java SDK that can be used to get the active message count.
Using com.microsoft.azure.management.servicebus : MessageCountDetails Class has activeMessageCount method that returns the activeMessageCount value.
Using com.microsoft.azure.servicebus.management : MessageCountDetails Class has getActiveMessageCount method that returns the activeMessageCount value.