The Java EE 6 Tutorial

ProcedureTo Build, Package, Deploy, and Run transactedexample Using NetBeans IDE

  1. In a terminal window, go to the following directory:

    tut-install/examples/jms/advanced/transactedexample/
    
  2. Create the necessary resources using the following command:


    ant create-resources
    

    This command creates three destination resources with the names jms/AQueue, jms/BQueue, and jms/CQueue, all of type javax.jms.Queue, and one destination resource with the name jms/OTopic, of type javax.jms.Topic.

  3. To compile and package the client, follow these steps:

    1. In NetBeans IDE, select File->Open Project.

    2. In the Open Project dialog, navigate to:


      tut-install/examples/jms/advanced/
      
    3. Select the transactedexample folder.

    4. Select the Open as Main Project check box.

    5. Click Open Project.

    6. In the Projects tab, right-click the project and select Build.

  4. To deploy and run the client, follow these steps:

    1. Right-click the transactedexample project and select Properties.

    2. Select Run from the Categories tree.

    3. In the Arguments field, type a number that specifies the number of computers to order:

      3

    4. Click OK.

    5. Right-click the project and select Run.

    The output looks something like this (along with some application client container output):


    Quantity to be ordered is 3
    Retailer: ordered 3 computer(s)
    Vendor: Retailer ordered 3 Computer(s)
    Vendor: ordered 3 monitor(s) and hard drive(s)
    Monitor Supplier: Vendor ordered 3 Monitor(s)
    Monitor Supplier: sent 3 Monitor(s)
      Monitor Supplier: committed transaction
      Vendor: committed transaction 1
    Hard Drive Supplier: Vendor ordered 3 Hard Drive(s)
    Hard Drive Supplier: sent 1 Hard Drive(s)
    Vendor: Completed processing for order 1
      Hard Drive Supplier: committed transaction
    Vendor: unable to send 3 computer(s)
      Vendor: committed transaction 2
    Retailer: Order not filled
    Retailer: placing another order
    Retailer: ordered 6 computer(s)
    Vendor: JMSException occurred: javax.jms.JMSException: 
    Simulated database concurrent access exception
    javax.jms.JMSException: Simulated database concurrent access exception
            at TransactedExample$Vendor.run(Unknown Source)
      Vendor: rolled back transaction 1
    Vendor: Retailer ordered 6 Computer(s)
    Vendor: ordered 6 monitor(s) and hard drive(s)
    Monitor Supplier: Vendor ordered 6 Monitor(s)
    Hard Drive Supplier: Vendor ordered 6 Hard Drive(s)
    Monitor Supplier: sent 6 Monitor(s)
      Monitor Supplier: committed transaction
    Hard Drive Supplier: sent 6 Hard Drive(s)
      Hard Drive Supplier: committed transaction
      Vendor: committed transaction 1
    Vendor: Completed processing for order 2
    Vendor: sent 6 computer(s)
    Retailer: Order filled
      Vendor: committed transaction 2
  5. After you run the client, you can delete the physical destinations and the destination resources. Go to the directory tut-install/examples/jms/advanced/transactedexample/ and type the following command:


    ant delete-resources