Pages

Sunday, September 25, 2011

How to create JMS resources from CLI in GlassfishV3

We'll look at how JMS resources specifically Queues (PTP model) & Topics (Pub-Sub model) can be created by the asadmin tool.

There is always this admin console (GUI mode) in Glsssfish which you can use to create all the resource types you need in applications. But the CLI tool (i.e.: asadmin) provided with the distribution also can be very handy if you need to create the resources for quick testing. We'll see how we can use this to create JMS resources specifically Queues and Topics:

Queue:
[Vijitha@localhost bin]$ ./asadmin create-jms-resource --restype=javax.jms.Queue --description="PTP Test queue" jms/MyPTPQueue 
Authentication failed with password from login store: /home/Vijitha/.asadminpass
Enter admin password for user "admin"> 
Administered object jms/MyPTPQueue created.
Command create-jms-resource executed successfully.

You may verify this either by CLI or the admin GUI console.

1. CLI:
[Vijitha@localhost bin]$ ./asadmin list-jms-resources
Authentication failed with password from login store: /home/Vijitha/.asadminpass
Enter admin password for user "admin">
jms/MyPTPQueue
Command list-jms-resources executed successfully.
2. Admin GUI console: Resources -> JMS Resources -> Destination Resources


Topic:
[Vijitha@localhost bin]$ ./asadmin create-jms-resource --restype=javax.jms.Topic --description="Pub/Sub test topic" jms/MyTopic
Authentication failed with password from login store: 
/home/Vijitha/.asadminpass
Enter admin password for user "admin">
Administered object jms/MyTopic created.
Command create-jms-resource executed successfully.

You may verify this either by CLI or the admin GUI console.

1. CLI:
[Vijitha@localhost bin]$ ./asadmin list-jms-resources
Authentication failed with password from login store: /home/Vijitha/.asadminpass
Enter admin password for user "admin">
jms/MyTopic
Command list-jms-resources executed successfully 
2. Admin GUI console: Resources -> JMS Resources -> Destination Resources