Configure JMS-AddressList property in Glassfish dynamically [Update]

When you would like to use a scenario like “Consuming JMS-Messages from a remote server” (see here), you may explore very quickly the problem, which comes with this example: The hard-coded “AddressList” property.

This is a problem, because it reduces the resuability to null. Testing or deploying on other system configurations would lead to code modifications. This modifications may follow a new testing and building time, etc. etc..

How to solve this problem?

The solution is very easy:

First, you have to decide which server should be the JMS master. Here I will choose the sending server.

Sending server

In the administration console of your sending glassfish go to

Configurations > server-config > Java Message Service

Set the JMS Service Type  to Local.

Go to the default_JMS_host and set the hostname to the name of your server or 0.0.0.0.

Restart the server.

Receiving server

In the administration console of your receiving glassfish go to

Configurations > server-config > Java Message Service

Set the JMS Service Type  to Remote.

Go to the default_JMS_host and set the hostname to the name of your sending server.

Restart the server.

If you would like to use more than one sending server or an additional local one, you must do the following steps.

Resources -> Connectors -> Connector Connection Pools -> [Your Connection Factory]

At the Additional Properties Page add a new property named AddressList with the name of your remote sending host.

Now you can receive messages from your remote host, without the need to configure this dependency hard-coded in your message bean.

 
1 Kudos
Don't
move!

6 thoughts on “Configure JMS-AddressList property in Glassfish dynamically [Update]

  1. I tried this solution and it did not work. I found that my message-driven bean was still not receiving messages from the host that was sending messages.



      1. I am using EJB 3 with GlassFish version 3.1.2. In the newly-created AddressList property in Resources -> Connectors -> Connector Connection Pools -> [My Connection Factory] window of the GlassFish Admin Console of the machine receiving JMS messages, I first put this value: [IP address of the host machine sending JMS messages]:7676. Then I restarted both the machine receiving messages and the machine sending JMS messages. I found that the receiving machine was no longer receiving messages now. Then I changed the AddressList property of this machine to this value: mq://[IP address of the sending machine]:7676. This did not work either. Can you please let me know what I am doing wrong? Can you also please provide me with screenshots to make it more helpful?


  2. I forgot to mention one more thing: I am using Publish/Subscribe messaging in which I am trying to publish a JMS message to be consumed by multiple subscribers. Will the example given here work also for Publish/Subscribe messaging, or is it only for Point-to-Queue messaging?

    In the GlassFish Admin Console of the machine that is sending the JMS message, I have configured the default JMS host to be 0.0.0.0. In the GlassFish Admin Consoles for the machine sending JMS messages and the machines receiving them, I have selected Embedded as the value in the Type dropdown in the Configurations > server-config > Java Message Service page. Are these settings correct?



    1. Hi Kalpana,

      sorry for the long delay, had to much trouble due to the last weeks.

      I checked my settings and what I’ve done was the following:
      Sending host
      – default_JMS_host hostname ‘0.0.0.0’ for default JMS
      JMS Service Type to ‘LOCAL’

      receiving host
      – default_JMS_host hostname ‘‘ for default JMS
      JMS Service Type to ‘REMOTE’

      This works for both Topic and Queue. If you would like to use multiple hosts and / or a local JMS broker than you have to specify the addressList property additionally.

      I hope this helps


Leave a Reply

Your email address will not be published. Required fields are marked *