How to use SQS Client to invoke SQS service in message broker

  1. Create SQS Client Code

    Generate code from wsdltojava tool. See following figure





















    Unzip given zip file from wsdl to java tool and open it with some IDE(eclipse or idea). Use following command to create idea project
    mvn idea:idea

    Build project with maven using the command
    mvn clean install

    Then we have to add necessary jars to class path
    First run ant command inside your message broker product as follows
    packs/wso2mb-1.0.2/bin$ ant
    Then this will copy jars to repository/lib folder inside your pack. We have to add those jars to class path of created project(Eclipse or idea)















    Then build your project using ide. If it complaints about axiom or rampart jars please remove them from the class path(remove any axiom jars except version 1.2.11.wso2v1)

    Then add SQSClient java code to project. We must run the main method in this class in order to run the SQS operations. Code is available at following url http://wso2.org/project/message-broker/1.0.2/docs/samples/sqs_soap_client.html
    Change the "accessKey" and the "secretAccessKey" in sqsClient.java code to the keys which can be found at "Home > Manage> Message Boxes(SQS)> Access Keys" of wso2mb server














  1. Run sqsClient java code and you will see following output in terminal
    createQueueResponse.getCreateQueueResult().getQueueUrl() = http://localhost:9763/services/MessageQueue/admin/Shared
    createQueueResponse.getCreateQueueResult().getQueueUrl() = http://localhost:9763/services/MessageQueue/admin/Shared
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    message_type0.getBody() = TEST MESSAGE
    createQueueResponse.getCreateQueueResult().getQueueUrl() = http://localhost:9763/services/MessageQueue/admin/Shared
    createQueueResponse.getCreateQueueResult().getQueueUrl() = http://localhost:9763/services/MessageQueue/admin/Shared

No comments:

Post a Comment

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...