Zied ABID
Wed, 16 Apr 2008 05:18:11 -0700
Hi again, this is what I code , you can take an idea : PongTest is a subscriber that wait for a "ping" messagePingTest is a publisher that wait for a "pong" message after sending a "ping" message and calculate the latency
I hope that help you littlePS : running in console with correct argument for server, port ,CallBack port ....
Zied Mohannad a écrit :
thanks Zied,These files will be helpful. However, I need tools for measurement. I used jconsole but I didn't find for example a way to measure the time delay or packet transmission time.Is there any function in Jconsole will help to support this ? Thanks, MohannadOn Wed, Apr 16, 2008 at 12:01 PM, Zied ABID <[EMAIL PROTECTED]> wrote:Dear Mohannad, If I understand, you want just use xmlBlaster to publish and receive message, so you should take a look on javaClients HelloWorld in $XMLBLASTER_HOME/demo/javaClients specially : HelloWorldPublish and HelloWorldSubscribe $XMLBLASTER_HOME/demo/HelloWorld6 is helpful too to have an idea on protocol's configuration I'm begging also in xmlBlaster , so I hope that is helpful Zied Mohannad a écrit : thanks Marcel, I need the XMLBlaster for just publish messages and the clients simply will receive them. So by changing the code of Java file in the client side (will lead somehow to different seniors), and then we can take some approximate measurements. If this possible at least to build some approximation and not necessary to be very accurate, I will be appreciate it if you could help us to make it by this Middleware package. Thanks again, Mohannad On Wed, Apr 16, 2008 at 11:00 AM, Marcel Ruff <[EMAIL PROTECTED] <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>>> wrote: Mohannad wrote: Dear Marcel, I'm new here for using XMLBlaster. I am working with my college in my university on project which depends totally on XMLBlaster package. We need the package for testing several protocols on different operating systems (different objects also) by changing the loads that sent. This will help to decide which protocol is better than other in specific loads. My doctor in my university suggested to use XMLBlaster since it has powerful capability to monitor the real time and then calculate statistics (e.g number of messages sent in specific time period) I tried to figure out that capabilities by using jconsole, but I could not find these real time monitoring for my project's goal. Could you help me to find a way to accomplish our project goal? Hi Mohannad, you plan a scientific task. To do such performance measurements you need to create an accurate experimental setup and precisely define the measurement points with minimal 'noise' (cross effects etc) in between. This needs to be coded depending on what your goals are and can't be generally done by a middleware. I wish you success, Marcel Thanks Marcel, Mohannad -- Marcel Ruff http://www.xmlBlaster.org http://watchee.net Phone: +49 7551 309371-- Mo|-|annad-وما توفيقي الا بالله - -- Mo|-|annad-وما توفيقي الا بالله -
// from xmlBlaster/demo/HelloWorld2.java
import org.xmlBlaster.util.Global;
import org.xmlBlaster.util.SessionName;
import org.xmlBlaster.util.XmlBlasterException;
import org.xmlBlaster.client.qos.ConnectQos;
import org.xmlBlaster.client.qos.PublishQos;
import org.xmlBlaster.client.I_Callback;
import org.xmlBlaster.client.key.PublishKey;
import org.xmlBlaster.client.key.UpdateKey;
import org.xmlBlaster.client.qos.UpdateQos;
import org.xmlBlaster.client.I_XmlBlasterAccess;
import org.xmlBlaster.util.MsgUnit;
public class PingTest implements I_Callback
{
private String oid="test";
private Global glob;
I_XmlBlasterAccess con;
long fin = -1L;
long debut = -1L;
long latence = -1L;
public PingTest(final Global glob) {
try {
this.glob =glob;
// Parametre de connexion ( Obligatoire )
String[] args = { "-protocol", "XMLRPC",
"-dispatch/connection/plugin/xmlrpc/hostname", "xerxes",
//"-dispatch/connection/plugin/xmlrpc/port","8080",
// "-dispatch/callback/plugin/xmlrpc/hostname","misti",
"-dispatch/callback/plugin/xmlrpc/port","40500"
};
glob.init(args);
con=glob.getXmlBlasterAccess();
ConnectQos qos = new ConnectQos(glob);
con.connect(qos, this); // Login to xmlBlaster, register for updates
System.out.println("Envoie d'un ping");
debut=System.currentTimeMillis();
System.out.println("debut : "+debut);
send("ping");
//subscribe
con.subscribe("<key oid='test'/>", "<qos/>");
// A similar subscription with XPATH:
//con.subscribe("<key oid='' queryType='XPATH'>//[EMAIL PROTECTED]'HelloWorld2']</key>", "<qos/>");
// wait a second
// try { Thread.sleep(1000); } catch(Exception e) { }
// Global.waitOnKeyboardHit("\nHit a key to logout and terminate ...");
//
//
}
catch (Exception e) {
System.err.println(e.getMessage());
}
}
void send(String cont)
{
PublishKey pk = new PublishKey(glob, oid, "text/xml", "1.0");
PublishQos pq = new PublishQos(glob);
pq.setPersistent(false);
byte[] content = cont.getBytes();
MsgUnit msgUnit = new MsgUnit(pk, content, pq);
try {
// publish
con.publish(msgUnit);
} catch (XmlBlasterException e) {
System.err.print(e);
}
}
//update : reception d'un message
public String update(String cbSessionId, UpdateKey updateKey, byte[] content,
UpdateQos updateQos)
{
// System.out.println("\nHelloWorld: Received asynchronous message '" +
// updateKey.getOid() + "' state=" + updateQos.getState() + " from xmlBlaster");
String receive = new String(content);
if (receive.equals("pong")) {
// try {
// Thread.sleep(100);
//} catch (InterruptedException e1) {
// System.err.println(e);
//}
fin=System.currentTimeMillis();
System.out.println("fin : "+fin);
latence = (fin-debut)/2;
System.out.println("latence : "+latence);
try {
con.erase("<key oid='HelloWorld2'/>", null);
} catch (XmlBlasterException e) {
e.printStackTrace();
}
con.disconnect(null);
}
return "";
}
/**
* Try
* <pre>
* java HelloWorld2 -help
* </pre>
* for usage help
*/
public static void main(String args[]) {
Global glob = new Global();
if (glob.init(args) != 0) { // Get help with -help
System.out.println(glob.usage());
System.out.println("Example: java HelloWorld2 -session.name Jack");
System.exit(1);
}
PingTest ping = new PingTest(glob);
}
}
//from xmlBlaster/demo/HelloWorld2.java
import org.xmlBlaster.util.Global;
import org.xmlBlaster.util.SessionName;
import org.xmlBlaster.util.XmlBlasterException;
import org.xmlBlaster.client.qos.ConnectQos;
import org.xmlBlaster.client.qos.PublishQos;
import org.xmlBlaster.client.I_Callback;
import org.xmlBlaster.client.key.PublishKey;
import org.xmlBlaster.client.key.UpdateKey;
import org.xmlBlaster.client.qos.UpdateQos;
import org.xmlBlaster.client.I_XmlBlasterAccess;
import org.xmlBlaster.util.MsgUnit;
public class PongTest implements I_Callback
{
private String oid="test";
private Global glob;
I_XmlBlasterAccess con;
public PongTest(final Global glob) {
try {
this.glob =glob;
// Parametre de connexion ( Obligatoire )
String[] args = { "-protocol", "XMLRPC",
"-dispatch/connection/plugin/xmlrpc/hostname", "xerxes",
//"-dispatch/connection/plugin/xmlrpc/port","8080",
// "-dispatch/callback/plugin/xmlrpc/hostname","misti",
"-dispatch/callback/plugin/xmlrpc/port","40600"
};
glob.init(args);
con=glob.getXmlBlasterAccess();
ConnectQos qos = new ConnectQos(glob);
con.connect(qos, this); // Login to xmlBlaster, register for updates
//subscribe
con.subscribe("<key oid='test'/>", "<qos/>");
// A similar subscription with XPATH:
//con.subscribe("<key oid='' queryType='XPATH'>//[EMAIL PROTECTED]'HelloWorld2']</key>", "<qos/>");
// wait a second
// try { Thread.sleep(1000); } catch(Exception e) { }
// Global.waitOnKeyboardHit("\nHit a key to logout and terminate ...");
//
//
}
catch (Exception e) {
System.err.println(e.getMessage());
}
}
void send(String cont)
{
PublishKey pk = new PublishKey(glob, oid, "text/xml", "1.0");
PublishQos pq = new PublishQos(glob);
pq.setPersistent(false);
byte[] content = cont.getBytes();
MsgUnit msgUnit = new MsgUnit(pk, content, pq);
try {
// publish
con.publish(msgUnit);
} catch (XmlBlasterException e) {
System.err.print(e);
}
}
//update : reception d'un message
public String update(String cbSessionId, UpdateKey updateKey, byte[] content,
UpdateQos updateQos) throws XmlBlasterException
{
// System.out.println("\nHelloWorld: Received asynchronous message '" +
// updateKey.getOid() + "' state=" + updateQos.getState() + " from xmlBlaster");
String receive = new String(content);
if (receive.equals("ping")) {
System.out.println("ping recu, envoie du pong");
send("pong");
try {
Thread.sleep(1000);
con.erase("<key oid='test'/>", null);
con.disconnect(null);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return "";
}
/**
* Try
* <pre>
* java HelloWorld2 -help
* </pre>
* for usage help
*/
public static void main(String args[]) {
Global glob = new Global();
if (glob.init(args) != 0) { // Get help with -help
System.out.println(glob.usage());
System.out.println("Example: java HelloWorld2 -session.name Jack");
System.exit(1);
}
new PongTest(glob);
System.out.println("Debut pong");
}
}