Tuesday, 7 August 2018

Enabling remote (out of container) jms client connection to JBoss 7.1 with embedded HornetQ 2.2.11

Enable your messaging subsystem by using the standalone-full.xml configuration file that is already provided in the installation.

Go to [your-jboss-installation-directory]/bin/standalone.conf(.bat for windows). Set the following attribute to point to your standalone-full.xml, instead of standalone.xml configuration file :

       
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.server.default.config=standalone-full.xml"


Call the  [your-jboss-installation-directory]/bin/add-user command, add an application user with the role of guest :

       
C:\work\development\jboss-as-7.1.0.Final\bin>add-user.bat
Picked up _JAVA_OPTIONS: -Duser.home=C:\Users\dubduan

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a):b



Enter the details of the new user to add.
Realm (ApplicationRealm) :
Username : guest
Password :
Re-enter Password :
What roles do you want this user to belong to? (Please enter a comma separated l
ist, or leave blank for none) : guest
About to add user 'guest' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'guest' to file 'C:\work\development\jboss-as-7.1.0.Final\standalone\
configuration\application-users.properties'
Added user 'guest' to file 'C:\work\development\jboss-as-7.1.0.Final\domain\conf
iguration\application-users.properties'
Added user 'guest' with roles guest to file 'C:\work\development\jboss-as-7.1.0.
Final\standalone\configuration\application-roles.properties'
Added user 'guest' with roles guest to file 'C:\work\development\jboss-as-7.1.0.
Final\domain\configuration\application-roles.properties'
Press any key to continue . . .






Edit the file [your-jboss-installation-directory]/standalone/configuration/standalone-full.xml, disable security by adding the security-enabled tag :

       


<subsystem xmlns="urn:jboss:domain:messaging:1.1">

<hornetq-server>

<security-enabled>false</security-enabled>

.

.

.

<subsystem>



Make sure to export both your factory and your queue. For example in this case the exported factory is jms/RemoteConnectionFactory, and the exported queue is jms/queue/test:



<subsystem xmlns="urn:jboss:domain:messaging:1.1">

<hornetq-server>

.

.

.

   <jms-connection-factories>
.

.

.

   <connection-factory name="RemoteConnectionFactory">
                       <connectors>
                           <connector-ref connector-name="netty"/>
                        </connectors>
                       <entries>
                           <entry name="RemoteConnectionFactory"/>
                           <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                        </entries>
                    </connection-factory>
   </jms-connection-factories>
   <jms-destinations>
          <jms-queue name="testQueue">
                        <entry name="queue/test"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
          </jms-queue>
   </jms-destinations>

.

.

.

<subsystem>

Here are the JMS connection attributes required for connection above (queue name, user, and password are yours to put):

       
initialContextFactory =  org.jboss.naming.remote.client.InitialContextFactory
url =  remote://localhost:4447
connectionFactory = jms/RemoteConnectionFactory
queue.jndiQueuName = jms/queue/test
user = guest
password = password

No comments:

About Me

My Photo