Sun MessageQueue – Install and Run

In this post I’d like to show my experience about installation and running of Sun Message Queue (SunMq).

As other services, SunMq is broker of Java Message Services (Jms) messages. I’ve found it very useful to split layers in multilayer application.

Sometimes happens that, in your application, you can accept the requests of some action and you can process it on different time. It’s typical of asyncronous requests when the client doesn’t expect a real time response from the server. Easily, the client accepts the acknowledge of the request which will be processed to the server after short or long time.

For example, an order process will be accepted even if the shipping won’t be done on real time.

Let’s get to work.

Once unpacked your SunMq package you can see the folder:


The first thing to do is to create a new broker. From folder /mq/bin/

sh imqbrokerd -name survey1 -cluster localhost:7680 -port 7680  &

Briefly, I made a broker with name “survey1” in cluster at port 7680.

To check the broker you have to use the command:

sh imqcmd list bkr -u admin -b localhost:7680

Remember the default password is “admin”.
You should get responses like this.

Listing all the brokers in the cluster that the following broker is a member of:
Host         Primary Port
localhost    7680
Cluster ID
Cluster is Highly Available   false
               Address                    State
test-jms-l1a:7680                       OPERATING
Successfully listed brokers in the cluster.

It’s time to create a Queue for sending and receiving message from. 

sh imqcmd create dst -t q -n Survey -b localhost:7680

I created a Queue of type “Queue” with name “Survey” on broker with port 7680.

Finally, we can expose the both ConnectionFactory and Queue to create connection file store. This will be used for client applications to use in obtaining broker connections for sending and receiving messages.

The queue:

sh imqobjmgr add -l "Survey" -j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory" -j "java.naming.provider.url=file:///store1/MessageQueueSurvey/var/mq/admobjstore" -t q -o "imqDestinationName=Survey"

The ConnectionFactory

sh imqobjmgr add -l "ConnectionFactory" -j "java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory" -j "java.naming.provider.url=file:///store1/MessageQueueSurvey/var/mq/admobjstore" -t cf -o "imqBrokerHostName=test-jms-l1a" -o "imqBrokerHostPort=7680"

We can check the work of this broker by jconsole and its property exposed by jmx. For connecting you can get the connection string by typing

telnet localhost 7680

The respose looks like


Put this string into jconsole and you can see all the broker health monitor.

Take a look inside the tab MBeans and com.sun.messaging.jms.server -> Destination -> Monitor -> q -> Survey -> Attributes. You can see at “NumMsgsIn” and “NumMsgsOut” the number of messages into the queue.

In conclusion, some references:

Administration Guide:

Installation Guide:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.