Running the Pipe Example

Once again, we must set up separate directories for the RestoPeer and the HungryPeer. After compiling the code, we can run it.

Let’s run the RestoPeer first and see what happens. After the platform initializes, we get this output:

Attempting to Discover the RestoNet PeerGroup
Could not find the RestoNet peergroup; creating one
RestoNet Restaurant (Chez JXTA) is on-line
Attempting to Discover the Restaurant RestoPipe
Could not find the Restaurant Pipe Advertisement
Created the Restaurant Pipe Advertisement
RestoNet Restaurant (Chez JXTA) waiting for HungryPeer requests

The RestoPeer instance (Chez JXTA) tries to find the RestoNet peergroup. Assuming you are on an isolated network and are running this from a new directory, it cannot find the existing peergroup, so it creates one. The RestoPeer then tries to discover its pipe advertisement. Again, since this is running in a new directory, the RestoPeer pipe advertisement is not found; the RestoPeer creates and publishes it and then waits for HungryPeer requests.

Let’s start running the HungryPeer instance:

Attempting to discover the RestoNet Peergroup Found the RestoNet PeerGroup Advertisement The HungryPeer joined the restoNet PeerGroup Locating RestoPeers in the RestoNet Peergroup Found 1 RestoPeers(s) Attempting to connect to discovered RestoPeer Connected pipe to RestoNet:RestoPipe:Chez JXTA Sent Fries Auction Request (medium) to connected peers Received Fries Bid from RestoPeers (Chez JXTA) at a Price ($2.50) ...

Get JXTA in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.