Samples demonstrating Java and .NET interop scenarios leveraging Spring support for vFabric components
The following vFabric components (Windows releases) must be installed and functional to run this sample:
- RabbitMQ (2.6.1)
- GemFire (v6.6)
- SQLFire (1.0 BETA)
-
install RabbitMQ service as per the RabbitMQ installation/getting-started instructions (recommended but not necessary: add the admin plugin, see http://www.rabbitmq.com/management.html)
-
start RabbitMQ service (windows Services control panel or command-line as preferred)
-
verify RabbitMQ service is running via the following command-line (switch to
rabbit-install-dir\sbin\
):C:\rabbitDir\sbin> rabbitmqctl status
-
If mgt plugin added, nav to RabbitMQ web admin portal (http://localhost:55672 [default creds: username=guest, password=guest)
-
Install GemFire as per the GemFire installation/getting-started instructions
-
copy the
cache.xml
file frompath-to-project-repo\gemfire-config\
to thegemfire-install-dir\bin\
folder -
start GemFire via the following command-line (switch to
gemfire-install-dir\bin\
):C:\gemfire-install-dir\bin> cacheserver start
-
verify GemFire started via the following command-line:
C:\gemfire-install-dir\bin> cacheserver status
-
Install SQLFire as per the SQLFire installation/getting-started instructions
-
start the server via the following command-line (switch to
sqlfire-install-dir\bin\
):C:\sqlfire-install-dir\bin> sqlf server start -dir=path-to-data-dir
[note: path-to-data-dir can be an empty folder, but the folder must already exist] -
start
sqlf>
prompt via the following command-line:C:\sqlfire-install-dir\bin> sqlf
-
connect to the running server via the following command-line:
sqlf> connect client 'localhost:1527'
[note: single quotes must surround the hostname:portnumber argument as shown]
-
run the script to create the SQLFire table and sequence via the following command-line (note: even on Windows OS, the path delimiters must be passed as
/
instead of\
):sqlf> run 'path-to-project-repo/sqlfire_setup_scripts/sqlfire_create_schema.sql'
[note: single quotes must surround the file-to-run argument as shown]
-
run the script to populate the SEQUENCE with the initial value via the following command-line:
sqlf> run 'path-to-project-repo/sqlfire_setup_scripts/sqlfire_populate_data.sql'
[note: single quotes must surround the file-to-run argument as shown]
Once the vFabric components are installed/configured properly, the following .NET and Java application(s) must be running for the sample to function properly:
- Java Server App
- .NET Windows Forms Client App
- .NET ASP.NET MVC Web Trade Reporter App
- .NET Credit Check REST service endpoint (hosted in ASP.NET MVC App)
The default configuration settings for these applications assume all are to be deployed on the same computer, but these applications can be deployed on the same or different computers from each other (some configuration changes will be needed for deployment to multiple systems).
NOTE: The following steps assume that you want to run the sample Java and .NET applications from within their respective IDEs so that you can inspect the code, set breakpoints, etc. This is expected to be the more common scenario for running these sample applications, but its not strictly necessary. Any valid mechanism (command-line, etc.) may be used to launch these sample applications to begin to interact with the system.
- Open the project
path-to-project-repo/java/stocks/
in SpringSource Tool Suite (or another Java IDE of your choice) - Run the
Server.java
package located inpath-to-project-repo/java/stocks/src/test/java/org/springframework/amqp/rabbit/stocks
- Open the
path-to-project-repo\net\StockTraderSample\Spring.Interop.StockTraderSample.sln
file in Visual Studio 2010 or later - Launch a DEBUG instance of the
Spring.Interop.StockTraderSample.Client.2010
project (right-click on the project in the Solution Explorer window and selectDebug --> Start new instance
) - Launch a DEBUG instance of the
Spring.Interop.StockTraderSample.ReportingWebApp.2010
project (right-click on the project in the Solution Explorer window and selectDebug --> Start new instance
). By default this web application will listen on PORT 1000. - Launch a DEBUG instance of the
Spring.Interop.StockTraderSample.CreditCheckService.2010
project (right-click on the project in the Solution Explorer window and selectDebug --> Start new instance
). By default this web application will listen on PORT 1100.
- The Java Server App contains no UI; once it is started, it will begin broadcasting stock QUOTE messages and listening for stock BUY and SELL messages.
- Use the START and STOP buttons to control the client listening for stock QUOTE messages from the Java-based server.
- Change the value in the Routing Key textbox and click the APPLY button to change the filtering of QUOTE messages received; this filtering is not merely applied to the listbox displaying the quotes, but controls the scope of the QUOTE messages that are received by the client from the server.
- To submit a BUY or SELL message to the server enter a valid stock ticker symbol into the Symbol textbox. For the purposes of this sample system, only stock ticker symbols that appear in the quotes listbox are considered valid by the system. Next, select either the Buy or Sell radio button, enter a quantity into the numeric control, and click the Send Trade Request button. This message will be received by the Java Server App, processed, and a response message returned to the Client App. If there are any errors, these will be returned to the Client App via messages from the Server App as well.
- Navigate to the application using your web browser of choice. By default, the application will be running at the http://localhost:1000/ URL.
- Click on the Activity Report tab to access the trade history data stored in SQLFire.
- Although this HTTP endpoint is hosted in an ASP.NET MVC application, there is no expected interaction with it via a UI.
- When the Java Server App processes a BUY message from the Client App, the Java Server App makes a call to this application to peform a credit check on the intended purchase. This service is hard-coded to accept any BUY order with a total value under $10,000 and to reject any BUY order with a value larger than that.