[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Howto perform Point 2 Point Messaging
>
> Hi Marcel,
>
> We are engaging in the development of an e-commerce system which would be using point 2
point messaging between servers.
>
> To throw some light on the problem, we have a product db and and Web db. When a product gets
added to the Product db we would like to send info of the same to the
Web db through a messaging
system. The Web db would listen for these messages and push the new data
into it's database.
Given our limited know-how about messaging solutions we think we require
a Point 2 Point
messaging service which XML Blaster supports.
>
> We realised while tinkering with XMLBlaster, that it be default runs in Publish-Subscribe mode
which is not what we are looking for.
>
> So it would be great if you could guide us with respect to how to get started with
implementing this system using Point 2 point messaging of XML blaster.
>
> Anticipating your help,
> Best Regds,
> Manpreet Singh
> --------------
> www.rediff.com
Hi Manpreet,
1. If you want to solve it by P2P:
==================================
ProductDb --Msg--> xmlBlaster --Msg--> WebDB
(example copied from
xmlBlaster/testsuite/org/xmlBlaster/TestPtDQueue.java):
a. Assume that the WebDB does a login with the loginName 'WebDB':
----------------------------------------------------------------
try {
receiverConnection = new CorbaConnection();
receiverConnection.login("WebDB", passwd, new LoginQosWrapper(),
this);
} catch (XmlBlasterException e) {}
...
public void update(String loginName, UpdateKey updateKey,
byte[] content, UpdateQoS updateQoS)
{
// receiving PtP messages here
}
b. ProductDB uses following code to send the message:
-----------------------------------------------------
String xmlKey = "<key oid='' contentMime='text/plain'>\n" +
"</key>";
String qos = "<qos>" +
" <destination queryType='EXACT'>" +
" WebDB" +
" <ForceQueuing />" +
" </destination>" +
"</qos>";
String content = "The new product data ...";
MessageUnit msgUnit = new MessageUnit(xmlKey,
content.getBytes(),
qos);
try {
publishOid = connection.publish(msgUnit);
Log.info(ME, "Sending done, returned oid=" + publishOid);
} catch(XmlBlasterException e) {}
Note the destination tag with the receiver login name "WebDB"!
2. If you want to solve it by Publish/Subscribe:
================================================
This is smarter, as any other client can listen on the update
messages, whithout changing the code from ProductDB or WebDB
if you have to in future.
ProductDb --Msg--> xmlBlaster +--Msg--> WebDB
|
+--Msg--> PerlStatisticClient
|
+--Msg--> C++Logger
|
+--Msg--> SAP-BillingClient
(Example copied from
xmlBlaster/testsuite/org/xmlBlaster/TestSubExact.java):
a. ProductDB sends the message:
------------------------------
String xmlKey = "<key oid='MyWebApp.ProductUpdate'
contentMime='text/plain'>"
"</key>";
String content = "Yeahh, i'm the new product with cheaper pricings";
MessageUnit msgUnit = new MessageUnit(xmlKey, content.getBytes(),
"<qos></qos>");
try {
senderConnection.publish(msgUnit);
} catch(XmlBlasterException e) {}
b. WebDB subscribes to this messages:
-------------------------------------
String xmlKey = "<key oid='MyWebApp.ProductUpdate'
queryType='EXACT'>\n" +
"</key>";
String qos = "<qos></qos>";
try {
connection.subscribe(xmlKey, qos);
} catch(XmlBlasterException e) {}
public void update(String loginName, UpdateKey updateKey,
byte[] content, UpdateQoS updateQoS)
{
// receiving PubSub messages here
}
Note that we explicitly named the message 'MyWebApp.ProductUpdate'.
3. If you have different message types (topics) you could enhance it
e.g.
========================================================================
String xmlKey="<key oid='MyWebApp.ProductUpdate' queryType='EXACT'>"+
" <product id='toaster'/>" +
" <color>blue</color>" +
" </product>" +
"</key>";
and the receiver could choose independently which types
of messages he wishes (using XSLT-XPath):
String xmlKey = "<key oid='' queryType='XPATH'>\n" +
" /xmlBlaster/key//blue" +
"</key>";
subscribe(xmlKey, qos);
To receive only the 'blue' stuff.
The xmlKey is the meta data describing your product.
If in any future another data sink would need
to know about updated toasters, he could
just subscribe to it without touching the rest of
your application.
hope it helps,
enjoy
Marcel
--
Marcel Ruff
mailto:ruff at swand.lake.de
http://www.lake.de/home/lake/swand/
http://www.xmlBlaster.org