Short answer:
1 - Create an user on imqbroker (glassfish3\mq\bin\imqusermgr.exe).
2 - Edit the accesscontrol.properties file (myDomain\imq\instances\imqbroker\etc) and set which user can consume which topic.
Long answer:
1 - Execute via command prompt:
\glassfish3\mq\bin\imqusermgr add -varhome c:\glassfish3\glassfish\domains\myDomain\imq -u myuser -p mypass
This will create an user on imqbroker indicated by varhome
with specific username and password.
2 - In the accesscontrol.properties file (myDomain\imq\instances\imqbroker\etc), edit the section destination based access control
to something like that:
topic.myTopic.consume.allow.user=myUser topic.myTopic.consume.deny.user=* topic.*.consume.allow.user=*
This will allow myUser
consume myTopic
and deny other users. And the rest of the topics you have will continue to allow all users to consume them. Note that topic.*.consume.allow.user=*
does not replace the topic.myTopic.consume.deny.user=*
.
My code remained the same:
TopicConnection conn = connectionFactory.createTopicConnection("myuser", "mypass");