This process demonstrates the concept of an AppSpace for scaling an application. 
  
 
	 Prerequisites
 
		 
		  - TIBCO Enterprise Message must be running. 
		  
- To run this sample, you can either use 
			 TIBCO ActiveMatrix BusinessWorks™ 6.x client or 
			 ActiveMatrix BusinessWorks™ 5.x as a client. 
		  
- PostgreSQL Database should be installed and running on the machine. Create tables by using the related scripts for the engine database. 
		  
-  Sample uses default queue - 'queue.sample' of EMS server running on localhost. 
		  
Procedure
Setup the Domain
-  
		  In a terminal, navigate to 
			 TIBCO_HOME\bw\n.n\bin and type 
			 bwadmin. 
		   
		
-  
		  Create a Domain, AppSpace and AppNode: 
		   
		   
			 bwadmin[admin]> create domain MyDomain
bwadmin[admin]> cd MyDomain
bwadmin[admin@MyDomain]> create appspace MyAppSpace
bwadmin[admin@MyDomain]> cd MyAppSpace
bwadmin[admin@MyDomain/MyAppSpace]> create –httpPort 9999 appnode MyAppNode
 
 
Create the config.ini File
-  
		  Copy 
			 TIBCO_HOME\bw\n.n\config\appspace_config.ini_template to a temporary location. 
		   
		
-  
		  Rename the 
			 appspace_config.ini_template file to 
			 config.ini. 
		   
		   
			 -  
				Uncomment the following property and change the value to group. 
				 
				 
				  bw.engine.persistenceMode=group 
 
-  
				Set the datastore configuration with values similar to: 
				 
				 
				  # BW Engine Database Driver. 
bw.engine.db.jdbcDriver=org.postgresql.Driver
# BW Engine Database URL.
bw.engine.db.url=jdbc:postgresql://localhost:5432/postgres1
# BW Engine Database User Name.
bw.engine.db.userName=postgres
# BW Engine Database User Password.
bw.engine.db.password=root
# BW Engine Database Connection Pool Size.  
bw.engine.db.maxConnections=10 
 
-  
				Save the 
				  config.ini file. 
				 
				For the 
				  JMS Receive Message 
				  activity, load balancing is done by setting 
				  Max Jobs limit and the flow limit. If one instance is down, the other instance processes the messages. Thus avoiding any outage. For the 
				  HTTP Receiver 
				  activity, load balancing is done at the external load balancer level. If one instance is down, all requests are sent to the other instance. However, when you use load balancing with fault tolerance, a database is required. 
				 
 
-  
		  Push the configuration to the AppSpace running the following command in the bwadmin terminal: 
		   
		   
			 bwadmin[admin@MyDomain/MyAppSpace]> config -cf <temporary_location>/config.ini
 
 
-  
		  In the bwadmin terminal, upload and deploy the EAR file into the AppSpace: 
		   
		   
			 bwadmin[admin@MyDomain/MyAppSpace]>upload
TIBCO_HOME\bw\x.x\samples\core\admin\ears\samples\tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.application_1.0.0.ear bwadmin[admin@MyDomain/MyAppSpace]> deploy -as
tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.application_1.0.0.ear 
 
-  
		  Start the AppSpace using the following command: 
		   
		   
			 bwadmin[admin@MyDomain/MyAppSpace]> start appspace MyAppSpace 
 
Configure and Start the Client
-  
		  Start TIBCO Designer and click 
			 New Empty Project. 
		   
		
-  
		  Click 
			  and import the client project, 
			 TIBCO_HOME\bw\n.n\samples\core\scalability\LoadBalancingUsingAppSpace\bw5\tibco.bw.sample.core.scalability.LoadBalancingUsingAppSpace.client. 
		   
		
-  
		  Update the JMS shared resource configuration and verify the Host and Port values. 
		   
		
-  
		  In TIBCO Designer, click 
			 . Wait for 30 seconds before completing the next steps. 
		   
		
Create a Second AppNode
-  
		  In the bwadmin terminal, create a second AppNode in MyAppSpace. Execute the create command to create the AppNode and then the start command to start the AppNode: 
		   
		  The 
			 TIBCO ActiveMatrix BusinessWorks™ JMS application should be deployed to 
			 MySecondAppNode automatically by the AppSpace. 
		    
			 
bwadmin[admin@MyDomain/MyAppSpace]> create –httpPort 9996 appnode MySecondAppNode
bwadmin[admin@MyDomain/MyAppSpace]> start appnode MySecondAppNode 
 
-  
		  Open the 
			 bwappnode.log files on each node located under 
			 <DomainLocation>/<appnodes>/<appspace>/<nodename>/log [Example: <DomainLocation>/appnodes/betaappspace/betaappnode1/log] 
			 and monitor the messages flow. 
		   
		
-  
		  Stop the second AppNode using the following command: 
		   
		   
			 bwadmin[admin@MyDomain/MyAppSpace]> stop appnode MySecondAppNode 
 
Result
 
		Before stopping the second AppNode, the application is active on both the nodes. After stopping the second AppNode, the application is active only on the first AppNode. See the 
		  bwappnode.log file to monitor the messages processed by AppNode1. 
		
 
	 Copyright © Cloud Software Group, Inc. All rights reserved.