Do you see the same behavior on the latest release of Wildfly?
Unfortunately I don't have wildfly installed on this server. Maybe I can put it on one of our test servers and give it a try tomorrow. But do you know if my syntax was incorrect? I just want to rule that out so I can make the case for trying to go to Wildfly 8
Your syntax looks correct to me, but I don't work much on the application server (I'm a HornetQ developer).
In any case, AS 7.1.1 is really old at this point. If you can't use the latest release of Wildfly for some reason then at least use the latest release of JBoss EAP (which is based on AS7 and has a ton of fixes beyond 7.1.1).
It should work, but bit more correct form would be something like this:
./jboss-cli.sh --user=abc --password=def --controller=18.104.22.168:9990 -c --commands="/subsystem=messaging/hornetq-server=default/jms-queue=MyQueue:read-attribute(name=message-count)"
in short, connect is not needed, as you passed "-c" which means connect on start. and exit is not needed as it will exit anyway.
other change is the extra / before :read-attribute, i am not sure if first one is correct but should be the same.
in any case try with some newer version as there ware lots of known problems with messaging subsystem and how it exposed data via CLI.