The Petstore Blueprint


Petstore is an implementation of the well-known application, now brought to the Inq platform. Apart from its familiarity, petstore's function not so important. Rather, it demonstrates much of what is possible with Inq when developing enterprise applications.

As well as a graphical client for account maintenance, composing and submitting an order and browsing orders and items, petstore includes a detached process to act as an order processor and an example of cooperation via a message broker. This context diagram depicts its components:



To run petstore you will need the following:


The implementation comes with typedefs bound to MySQL so to run it as-is requires access to a MySQL server. If running under Ubuntu, use the Synaptic Package Manager or install with apt-get install mysql-server-5.1. Otherwise download a version suitable for your platform here.

The runtime JDBC driver can be downloaded here. See below for where to place all third party jars so that the Inq server picks them up.

To run petstore against another SQL server implementation is a straightforward process. The following directories are relevant

schema creation and data load.
SQL for the various typedef keys and SQL server resource declaration.

Modifying the files therein should be self-explanatory. You can create ...petstore/<your-sql-server>/... and modify the server launch, changing the -db argument. Make sure there is a suitable JDBC driver jar file in the classpath - you may need to modify INQJDBCARGS in ./bin/inq

If you do run against a different SQL server then please contribute your efforts to the forums.

GlassFish >> Open Message Queue

Petstore reports completed orders to an "exchange" which in turn broadcasts "market prices" that "other petstores" can subscribe to. If there is no message broker available then this part of petstore will not run. You have the following alternatives:

  • Download and install Open Message Queue. Petstore (or more accurately Inq's JMS functionality) has been tested against this. More details are available in the JMS Mini Guide.
  • Modify the distribution to use the message broker you are using.
  • Don't bother with price reporting. The application will run without it but orders will never move to the shipped state and the Items Browser GUI will not show price movements.

Apache FOP

Petstore includes a demonstration of report production in Inq. We'll examine this aspect further in other sections but for now the process is broadly

  1. Gather the report content by building an appropriate node structure
  2. Convert this structure to an XML form that marries the content to the report layout by being sympathetic to the XSL templates (contained in $INQHOME/app/examples/petstore/reports)
  3. Submit the XML and XSL templates to Apache FOP to generate pdf output
  4. Transfer the pdf file to the client for view/print.

Note that report production takes place on the server, so the only support needed in the client is a pdf viewer set up as the desktop application for pdf files.

Setting up Apache FOP is optional - without it the reports (in the petstore My Orders screen) will not run. You can download it here or if you are running under Ubuntu, install it with sudo apt-get install fop.

Inq/petstore has been tested on Windows and Linux against versions 0.95 and 1.0 of Apache FOP, downloaded directly from the Apache Foundation. We have experienced stack overflow exceptions using the Ubuntu packaged version.

Running Petstore Online

If you just want to try out the demonstration without installing Inq, the required third-party components above and starting the server you can run the client via Java Webstarttm by clicking below.

Launch the petstore client (requires Java 1.6): launch

The login screen should appear.

  • The valid user name is ACID.
  • Any password will do
  • If you are behind a firewall then it must allow outbound connections on port 8003.

Fill it in as shown and click OK.

There is a limit of 50 users logged in at any one time (remember that the Inq client maintains a long-lived two-way connection with the server) and an idle timeout of 10 minutes, after which the session will be terminated. The good thing about the online demo is that assuming other people are logged in at the same time, you can see new orders being added in the My Orders window and price changes in Browse Items. Just click the Filter button in both cases.

We will endeavour to keep the server running at all times, resetting the database every so often.

Setting Up

Unpack the distribution in a convenient directory - in the instructions that follow we refer to this as $INQHOME.

Third Party Jars

Place the required third-party Jar files into the $INQHOME/lib/endorsed directory. Assuming you are using MySql and Open Message Queue your directory will look something like this:


Create and Load the Database

Perform the following:

cd $INQHOME/app/examples/petstore/db/mysql
mysql -uroot -pyour-password < jpetstore-mysql-schema.sql
mysql -uroot -pyour-password < jpetstore-mysql-dataload.sql

Start the Message Broker

If you are using GlassFish Open Message Queue then in a terminal window enter

./imqbrokerd -tty -loglevel DEBUGHIGH

where it is assumed the current directory is something like .../MessageQueue44/mq/bin

Start and Load the Server

Perform the following (expected output shown in bold):

bin/inq -server -db mysql &
Inq Server
Copyright (c) InqWell Ltd 2002-2011
Java Compiler Compiler Version 3.2 Copyright (c) 2003 Sun Microsystems, Inc. All  Rights Reserved.
DeadlockScanner Started
Server Started
speakinq Socket Listener Started on port 6556

To load the server do:

inq -load -u admin -p inqwell -server speakinq://localhost -url file:app/examples/petstore/psBoot.inq
-url file:app/examples/petstore/psBoot.inq is a relative URL resolved with respect to the current directory of the server, so this assumes you started the server in $INQHOME.

Starting the Pets International Exchange

If you are running the message broker then you should start the "exchange" mentioned above. This has been written as a command-line script - start it like this:

cd $INQHOME/app/examples/petstore
inq -in exchangeSimulator.inq -fill FILL.PIE -feed FEED.PIE

The exchange waits at the queue FILL.PIE for completed orders sent by petstore. It then simulates price movements on the order items and publishes them on the topic FEED.PIE. More on this later.

Starting the Client

Starting the Inq graphical client brings up the login screen as shown above.

inq -client
Inq Client
Copyright (c) InqWell Ltd 2002-2011
Java Compiler Compiler Version 3.2 Copyright (c) 2003 Sun Microsystems, Inc. All  Rights Reserved.
JDateChooser Copyright (c) Kai Toedter 1999 - 2006
TableLayout Copyright (c) 2001 Daniel Barbalace. All rights reserved.

When running locally (as opposed to logging into the server hosted at your login screen should look like this:

By default the server is not started with SSL enabled, so the URL to connect to locally is speakinq://... and not speakinqs://...

After logging in petstore displays its dashboard window: