|JAVA SOLUTION FOR B2B XML MESSAGES|
|JXTA, P2P, and the Resolver: Peer-to-Peer (P2P)|
|JXTA and P2P are new, so let's quickly
review what they are. P2P is often described as the sharing of processing,
storage, and services between personal computers. More specifically, P2P
favors the distribution of responsibility and resources, rather than
centralizing them on a server. JXTA is a specification that describes P2P
protocols and services for general P2P computing. The JXTA APIs that
implement the specification are designed with a high level of abstraction
that hides much of the drudgery of P2P. JXTA connects PDAs, cell phones,
desktops, and laptops into an addressable network of resources and
services. JXTA also solves many key problems of P2P computing, such as
firewalls, NAT devices, and DHCP, which prevent simple, direct connections
JXTA has two primary messaging systems: Pipe and the Resolver. There is quite a bit of literature on Pipes, which are similar to sockets, but much more abstract and a bit harder for client-server developers to grasp. The Resolver is not as widely known, mainly because it is used as a core messaging system in the JXTA platform for routing and searching. The Resolver follows a query-and-response pattern that is very useful and thus the focus of this article.
|A Resolver is a simply
query-and-response protocol. The client sends an XML message tagged with a
name and a payload. The target peers look for the name of the message,
process the payload, and return an answer if one is required. This is a
broadcaster-and-listener pattern of communications. The software pattern
is similar to a publish-and-subscribe, except that the scope of messages
is limited by a secondary mechanism called peer groups, rather than a
mechanism that routes messages based on a subscription request.
The Resolver also works in a mode we call propagation. Propagation, in P2P terms, is the forwarding of messages from computer to computer. Propagation is similar to broadcasting, except that each computer may forward the message to others, rather than everyone listening to the same message all at once. Propagation is important because protocols like IP Multicast only work in specific networks and usually not between local area networks.
The response to a Resolver query takes the best path back to its source (rather than broadcasting). This is possible because the originating peer ID is included in the query message. The JXTA router discovers the best route back and sends the message.
|Information is represented as XML|
|The information is represented as XML documents.|
|Demo of Resolver|
To demonstrate the Resolver, we'll now implement a simple broadcast ping. Rather than designate a specific computer, we'll propagate the message to ping any peer that is listening. Here's what we're going to cover: