vendredi 19 septembre 2008

How to register SwiftMQ broken in a Glassfish cluster

To register the swift MQ broker in cluster environnement you can use the following asadmin commands...

First you need to deploy the ressouce archive that contains the swift connector
asadmin deploy --host <hostname> --port <portNumber> -u admin --passwordfile=asadmin_password.txt   --target=domain --name swiftmq_rar swiftmq.rar


Replace the <hostname> and <portNumber> with respectiveley the host name and port number where is located the DAS that manages the cluster.

Register after the connector in the DAS
asadmin create-resource-adapter-config --host <hostname> --port <portNumber> -u admin --passwordfile=asadmin_password.txt   --property AllowOnePhase=false:IntraVM=false:DebugMode=false:ProviderURL="smqp\://<SWIFT_HOST>\:4001/timeout\=10000\;reconnect\=true\;retrydelay\=5000\;maxretries\=120" swiftmq_rar


The connector is registered under the name swiftmq_rar. You can see it through the admin console under the item "Applications/Connector modules".
Replace <SWIFT_HOST> with the name of the host where is located the broker

Now it's time to register the connection pool and connection factory which connects to the broker
asadmin create-connector-connection-pool --host <hostname> --port <portNumber> -u admin --passwordfile=asadmin_password.txt   --steadypoolsize 20 --maxpoolsize 100 --poolresize 2 --maxwait 60000 --raname swiftmq_rar --transactionsup
port XATransaction --connectiondefinition javax.jms.ConnectionFactory --property ConnectionFactoryName=ConnectionFactory swiftmq-shared-connection-pool


the connection pool is named swiftmq-shared-connection-pool.

asadmin create-connector-resource --host <hostname> --port <portNumber> -u admin --passwordfile=asadmin_password.txt   --target=domain --poolname swiftmq-shared-connection-pool  jms/ConnectionFactory


The jms/ConnectionFactory is linked with the swiftmq-shared-connection-pool;

Registering of a queue
Now we can register a queue. For the example, i will register the queue Notify on the router router1 on swift.
asadmin create-admin-object --host <hostname> --port <portNumber> -u admin --passwordfile=asadmin_password.txt   --target=domain --restype javax.jms.Queue --raname swiftmq_rar --property QueueName=Notify@router1  jms/Notify


The password file must contains the admin pasword and some time the master passord
AS_ADMIN_PASSWORD=adminadmin
AS_ADMIN_MASTERPASSWORD=changeit