Topic:   webMethods Broker queue lock/unlock using java code
Dec 12, 2012 10:40 5 Replies 2943 Views vinodini
Prev Next
Topic Replies (5)
  1. 1
    idnkx user

    vinodini

    Hi Folks,


    I would like to write a java code in webmethods server cluster environment to lock or unlock already existing webmethods broker Queue. Is it possible to acquire this through code?
    If so, pls provide any samples.

    I tried with java code which could only create a queue in webMethods queue and not able to alter already existing queue.

    Scenario:
    There was issue with the production ERP system and the ERP system was down for 30 mins and due to which lot of message processed in webMethods and tried to reach SAP but failed. So there were lots of messages failed.
    To handle this we have decided to lock the webmethods queue when there is any issues to connect to ERP system and unlock the queue when it is able to ping the ERP system. Which will prevent us from message lost.


    Please suggest me if there is any other solution to handle this situation.
    Regards,
    Vinodini.
    ======

    1
    idnkx user

    Vikram

    Hi Vinodini,

    If you want to work on Java code check [url=http://documentation.softwareag.com/webmethods/wmsuites/wmsuite8_ga/Broker_and_JMS/8-0-SP1_Broker_Java_Admin_Programmers_Guide.pdf]SAG guide[/url]. I think you may have to use "BrokerAdminClient.acquireChangeLock method" to lock/unlock.

    I did it for JMS messaging, to get Broker clients, description, storage, clientstats and JMS clients.

    [b]By importing the below classes:[/b]

    java.net.Socket
    java.net.DatagramSocket
    java.net.DatagramPacket
    java.net.InetAddress
    java.io.ByteArrayOutputStream
    java.io.PrintWriter
    java.io.OutputStream
    java.io.InputStream
    java.lang.Object
    java.io.BufferedReader
    java.io.InputStreamReader
    java.io.DataInputStream
    COM.activesw.api.client.BrokerClient
    COM.activesw.api.client.BrokerException
    COM.activesw.api.client.BrokerEvent
    COM.activesw.api.client.BrokerAdminClient
    java.net.*
    java.io.inputStream
    java.io.FileNotFoundException
    COM.activesw.api.client.BrokerConnectionDescriptor
    COM.activesw.api.client.enums.KeystoreType
    COM.activesw.api.client.enums.TruststoreType
    COM.activesw.api.client.*


    [b]Sample code which Returns stringlist (names) of all Broker Clients (queues):[/b]

    IDataCursor pipelineCursor = pipeline.getCursor();
    String brokerServer = IDataUtil.getString( pipelineCursor, "brokerServer" );
    String brokerName = IDataUtil.getString( pipelineCursor, "brokerName" );
    String keystore_file = IDataUtil.getString( pipelineCursor, "keystore_file" );
    String truststore_file = IDataUtil.getString( pipelineCursor, "truststore_file" );
    String password = IDataUtil.getString( pipelineCursor, "password" );
    try {
    // First enable the SSL security
    // Build the connection descriptor.
    BrokerConnectionDescriptor connectionDescriptor = new BrokerConnectionDescriptor();

    KeystoreType keystoreType = KeystoreType.PKCS12;
    TruststoreType truststoreType = TruststoreType.JKS;

    connectionDescriptor.setSSLCertificate (keystore_file, truststore_file, keystoreType, truststoreType, password);

    //Connect to broker
    BrokerAdminClient adminClient = new BrokerAdminClient(brokerServer.trim()
    , brokerName.trim()
    , null
    , "admin"
    ,"BrokerMonitoring"
    , connectionDescriptor );
    String[] client = adminClient.getClientIds();
    IDataUtil.put( pipelineCursor, "clientName", client);
    adminClient.disconnect();
    }
    catch (Exception e)
    {
    throw new ServiceException(e);
    }


    --> One other way is to use services at WMRoot to disable/enable/suspend triggers.

    [b]Check:[/b] WmRoot.wm.server.jms.suspendJMSTriggers, WmRoot.wm.server.triggers.suspendTrigger

    The services within the WmRoot package aren't meant to be used for our development needs. These services are used by the IS for its internal functionalities. Thus the WmRoot package isn't documented as a BIS reference guide.
    If you wish to use them then you need to make the package visible in the Developer and make sense of out of the inputs and outputs defined for a particular service.

    [b]Note:[/b] Do not use these services directly but use your own wrapper service instead to utilize their functionality.


    Hope this helps..
    Thanks

    1
    idnkx user

    vinodini

    Hi Vikram,


    Thanks alot for your reply.

    I was also checking the same document mentioned by you
    "webMethods Broker Administration Java API Programmer’s Guide"

    But I couldnt find any samples on how to use the method BrokerAdminClient.acquireChangeLock.
    It would be grateful if you could provide any samples on the acquireChangeLock methods.

    Thanks again.

    1
    idnkx user

    Vikram

    Refer my sample code and build up your own Java code according to your requiremnts...

    See webMethods Broker Administration Java API Programmer’s Guide" for more info on using changeLock functionality.

    Using Change Locks Page 40

    acquireChangeLock Page 170

    For more information on the BrokerChangeLockInfo object, see page 300.

    1
    idnkx user

    vinodini

    I have achieved the objective through below method by suspending and resuming triggers rather than locking/unlocking queues.

    I could suspend and resume the triggers using the below servcies by providing the trigger names
    Pub.trigger.suspendProcessing, Pub.trigger.resumeProcessing.

    Thanks alot for your help. :)

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect