WELCOME

for any suggestion's please mail to this id:

nanduriraja537@gmail.com,raja.mic539@gmail.com

Wednesday, June 20, 2012

Remote JMS with JBoss AS 7.1 / HornetQ JMS

When you want to connect to a Queue or Topic on JBoss Application Server 7.1.1 with a remote jms client you can follow the next steps.

First step is to add messaging configuration to the JBoss configuration xml. In this case I will use the standalone configuration.

Open standalone.xml located at jboss-as-7.1.1.Final\standalone\configuration

Add org.jboss.as.messaging to the extensions








Add the HornetQ messaging configuration, make sure it is the first xml entry after profile.





truepersistence-enabled>
102400journal-file-size>
2min-files>




















231.7.7.7group-address>
9876
5000broadcast-period>

netty






231.7.7.7group-address>
9876
10000refresh-timeout>





jms

nettyconnector-ref>















jms.queue.DLQaddress>
jms.queue.ExpiryQueue
0redelivery-delay>
10485760size-bytes>
BLOCKaddress-full-policy>
limit>10history-day-limit>
1000redistribution-delay>









/>


>




/>
























We will use

RemoteConnectionFactory as JMS ConnectionFactory with "java:jboss/exported/jms/RemoteConnectionFactory" as JNDI name. Use jms/RemoteConnectionFactory as CF reference in your java client.

queue/test as Queue with as jndi name "java:jboss/exported/jms/queue/test". Use jms/queue/test as Queue reference.

For remote it should start with java:jboss/exported/ else these object won't be exposed and then you can't lookup the CF or Queue.

Also for remote we need to create a application user. Go to the bin folder and start add-user.sh
Create a user jms with a password and add this user to the guest role. Guest role has permission for remote and jms.

Start JBoss with the standalone configuration.


For our java test clients we need to have a jboss and a HornetQ jar file.
First copy jboss-client.jar from the bin/client jboss folder and we need to download the lates HornetQ libraries ( hornetq-2.2.14.Final) . Copy hornetq-jms-client.jar from the HornetQ lib folder.

First the Jms Send Client


Jms Receive Client



In this example I use the same username , password for createQueueConnection
QueueConnection qcon = qconFactory.createQueueConnection("jms","jboss1");

If you don't do this you will get this error Unable to validate user: null

INFO: JBoss Remoting version 3.2.3.GA
Exception in thread "main" javax.jms.JMSSecurityException: Unable to validate user: null
at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:312)
Caused by: HornetQException[errorCode=105 message=Unable to validate user: null]

To solve this you can also disable messaging security
truepersistence-enabled>
102400journal-file-size>
2min-files>
falsesecurity-enabled>

Now you can also use QueueConnection qcon = qconFactory.createQueueConnection();

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...