Lightstreamer JMS Extender - Stock-List Demo - Java (JMS) Service
This project contains the source code and all the resources needed to install the Stock-List Demo Service for Lightstreamer JMS Extender.
The Stock-List Demo Service is stand-alone Java application that acts as a service, sending simulated stock quotes on a JMS topic. It provides data for client-side Stock-List Demos for JMS Extender, such as the HTML Demo and the Node.js Demo.
Note that this service makes no use of the JMS Extender APIs: it works by using directly the JMS APIs. For simplicity, a single JMS topic is used for all stocks, while in a real scenario you would probably use a different JMS topic for each stock.
Check out the sources for further explanations.
If you want to install a version of this demo pointing to your local Lightstreamer JMS Extender, you have to configure a JMS broker and deploy the service components. Please follow these steps:
Configure the JMS Broker
This demo needs a JMS infrastructure to run. You can choose whatever JMS broker you prefer to be used for this example. We will show 4 examples using HornetQ (AKA JBoss Messaging), TIBCO EMS, Apache ActiveMQ, and JBossMQ.
Once you have selected and installed your JMS broker, you will have to configure it accordingly to other components, in particular:
- You will have to copy JMS broker-specific jars in the connector directory and in the data generator directory.
- You will have to select the specific connection parameters in the connector configuration, the data generator, and the demo page.
HornetQ (AKA JBoss Messaging)
- You should configure a new topic. Open the
hornetq-jms.xmllocated under HornetQHome
/config/stand-alone/non-clusteredand add the following node:
<topic name="stocksTopic"> <entry name="stocksTopic"/> </topic>
- Copy the following jars:
/HornetQHome/lib. You will need to paste them later.
You should create a new topic. Open the
topics.conffile located under EMSHome
/bin/and append to it stocksTopic.
EMSHome/clients/java. You will need to paste them later.
There's no need to create topics or queues, because ActiveMQ supports dynamic configuration of destinations.
Copy the following jars:
/ActiveMQHome/lib, changing the version number accordingly to your installation. You will need to paste them later.
- You shold create a new topic. Open the
jbossmq-destinations-service.xmllocated under JBossHome
/server/default/deploy/jms/and add a mbean node as shown below:
<mbean code="org.jboss.mq.server.jmx.Topic" name="jboss.mq.destination:service=Topic,name=stocksTopic"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> </mbean>
JBossHome/client/. You will need to paste it later.
Deploy the Demo Service
To configure the demo service, follow these steps:
- Copy the
JMS_StockList_Demo_Servicedirectory you can find in the
deploy.zipfile from the latest release of this project, anywhere in your file system, and put previously copied jars under its
- Download the JMS distribution (version 1.1 or 2.0 depending on the broker version in use) from Oracle's Java website. It cannot be distributed with the JMS Extender for licensing issues. It can be found here: v1.1 v2.0.
- Extract its content and find the
jms.jarfile under the
libdirectory. Please copy this jar under the
libsubdirectory of the Demo Service.
- Then, configure the launch script
start_stocklist_demo_service.sh, if you are under Linux or Mac OS X), adding all the JMS broker-specific jars to the CUSTOM_JARS variable. It is preset with jars for HornetQ.
- Now you should edit the configuration file. The included
demo_service.conffile shows all available parameters and 4 sample configuration for the 4 JMS brokers above. Note that all parameters are required.
- Finally, check the log4j configuration file.
Once everything is configured, launch the service with
start_stocklist_demo_service.sh if you are under Linux or Mac OS X). The service must be running for the StockList Demo Client to function properly.
Running the Demo
- The JMS Extender StockList Demo requires a Lightstreamer JMS Extender instance running. Please refer to Lightstreamer web site download page to find Lightstreamer JMS Extender download packages.
- Now grab the jar of the service,
JMSStockListDemoService.jar, and copy it under the
jms_connectors/libfolder of the JMS Extender just deployed. This is needed since the Extender must be able to create any object sent or received by its clients. In this case the extender requires the declaration of the
Now you can test this demo running the Lightstreamer JMS Extender - Basic Stock-List Demo - HTML Client.
To build your own version of
JMSStockListDemoService.jar, instead of using the ones provided in the
deploy.zip file from the Install section above, follow these steps:
- Get the
log4j-1.2.17.jarfile from Apache log4j and copy it into the
- Make sure that the
jms.jarfile was copied into
libfolder of this project as from the Install section above.
- Create the jar
JMSStockListDemoService.jarwith commands like these:
$ javac -source 1.6 -target 1.6 -nowarn -g -classpath lib/log4j-1.2.17.jar;lib/jms.jar -sourcepath src/ -d tmp_classes src/jms_demo_services/JmsStockListDemoService.java $ jar cvf JMSStockListDemoService.jar -C tmp_classes jms_demo_services
Clients Using This Service
- Lightstreamer JMS Extender - Basic Stock-List Demo - HTML Client
- Lightstreamer JMS Extender - Basic Stock-List Demo - Node.js Client
- Lightstreamer - Stock-List Demo - Java Adapter
- Lightstreamer - Reusable Metadata Adapters - Java Adapter
- Lightstreamer JMS Extender - Portfolio Demo - Java (JMS) Service
Lightstreamer Compatibility Notes
- Compatible with Lightstreamer JMS Extender since version 1.5 or newer.