Permalink
Browse files

java_nats_0.4

  • Loading branch information...
1 parent 1c0d7d0 commit 03e289beadf0a96089265ff11b9b33f231a9d68e @tyagihas committed Aug 31, 2012
Showing with 7,947 additions and 452 deletions.
  1. +1 −1 .classpath
  2. +15 −15 README.md
  3. +8 −7 benchmark/{ → org}/nats/benchmark/PubPerf.java
  4. +11 −11 benchmark/{ → org}/nats/benchmark/PubSubPerf.java
  5. +3 −6 bin/PubPerf.bat
  6. +15 −3 doc/allclasses-frame.html
  7. +15 −3 doc/allclasses-noframe.html
  8. +62 −32 doc/constant-values.html
  9. +6 −4 doc/deprecated-list.html
  10. +10 −4 doc/help-doc.html
  11. +16 −8 doc/index-files/index-1.html
  12. +46 −10 doc/index-files/index-10.html
  13. +13 −31 doc/index-files/index-11.html
  14. +18 −8 doc/index-files/index-12.html
  15. +28 −18 doc/index-files/index-13.html
  16. +9 −7 doc/index-files/index-14.html
  17. +11 −9 doc/index-files/index-15.html
  18. +11 −7 doc/index-files/index-16.html
  19. +15 −11 doc/index-files/index-2.html
  20. +12 −10 doc/index-files/index-3.html
  21. +19 −13 doc/index-files/index-4.html
  22. +10 −8 doc/index-files/index-5.html
  23. +9 −7 doc/index-files/index-6.html
  24. +13 −9 doc/index-files/index-7.html
  25. +45 −9 doc/index-files/index-8.html
  26. +16 −10 doc/index-files/index-9.html
  27. +6 −3 doc/index.html
  28. +379 −0 doc/org/nats/MsgHandler.html
  29. +1,078 −0 doc/org/nats/Session.html
  30. +259 −0 doc/org/nats/benchmark/PubPerf.html
  31. +259 −0 doc/org/nats/benchmark/PubSubPerf.html
  32. +115 −0 doc/org/nats/benchmark/class-use/PubPerf.html
  33. +115 −0 doc/org/nats/benchmark/class-use/PubSubPerf.html
  34. +20 −0 doc/org/nats/benchmark/package-frame.html
  35. +137 −0 doc/org/nats/benchmark/package-summary.html
  36. +129 −0 doc/org/nats/benchmark/package-tree.html
  37. +115 −0 doc/org/nats/benchmark/package-use.html
  38. +218 −0 doc/org/nats/class-use/MsgHandler.html
  39. +157 −0 doc/org/nats/class-use/Session.html
  40. +259 −0 doc/org/nats/examples/AutoUnsub.html
  41. +259 −0 doc/org/nats/examples/Expected.html
  42. +259 −0 doc/org/nats/examples/MultiConnection.html
  43. +259 −0 doc/org/nats/examples/Pub.html
  44. +259 −0 doc/org/nats/examples/QueueSub.html
  45. +259 −0 doc/org/nats/examples/Request.html
  46. +259 −0 doc/org/nats/examples/Sub.html
  47. +259 −0 doc/org/nats/examples/SubTimeout.html
  48. +259 −0 doc/org/nats/examples/SubUnsub.html
  49. +115 −0 doc/org/nats/examples/class-use/AutoUnsub.html
  50. +115 −0 doc/org/nats/examples/class-use/Expected.html
  51. +115 −0 doc/org/nats/examples/class-use/MultiConnection.html
  52. +115 −0 doc/org/nats/examples/class-use/Pub.html
  53. +115 −0 doc/org/nats/examples/class-use/QueueSub.html
  54. +115 −0 doc/org/nats/examples/class-use/Request.html
  55. +115 −0 doc/org/nats/examples/class-use/Sub.html
  56. +115 −0 doc/org/nats/examples/class-use/SubTimeout.html
  57. +115 −0 doc/org/nats/examples/class-use/SubUnsub.html
  58. +27 −0 doc/org/nats/examples/package-frame.html
  59. +165 −0 doc/org/nats/examples/package-summary.html
  60. +136 −0 doc/org/nats/examples/package-tree.html
  61. +115 −0 doc/org/nats/examples/package-use.html
  62. +20 −0 doc/org/nats/package-frame.html
  63. +141 −0 doc/org/nats/package-summary.html
  64. +129 −0 doc/org/nats/package-tree.html
  65. +155 −0 doc/org/nats/package-use.html
  66. +5 −5 doc/overview-frame.html
  67. +5 −5 doc/overview-summary.html
  68. +22 −7 doc/overview-tree.html
  69. +3 −1 doc/package-list
  70. +4 −3 examples/{ → org}/nats/examples/AutoUnsub.java
  71. +5 −4 examples/{ → org}/nats/examples/Expected.java
  72. +6 −6 examples/{ → org}/nats/examples/MultiConnection.java
  73. +3 −2 examples/{ → org}/nats/examples/Pub.java
  74. +4 −3 examples/{ → org}/nats/examples/QueueSub.java
  75. +5 −6 examples/{ → org}/nats/examples/Request.java
  76. +4 −3 examples/{ → org}/nats/examples/Sub.java
  77. +5 −4 examples/{ → org}/nats/examples/SubTimeout.java
  78. +4 −3 examples/{ → org}/nats/examples/SubUnsub.java
  79. +41 −0 lib/org/nats/MsgHandler.java
  80. +153 −136 lib/{ → org}/nats/Session.java
View
@@ -4,6 +4,6 @@
<classpathentry kind="src" path="benchmark"/>
<classpathentry kind="src" path="examples"/>
<classpathentry kind="src" path="test"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -17,29 +17,29 @@ session.start();
session.publish("foo", "Hello World!", null, null);
// Simple Subscriber
-session.subscribe("foo", session.new EventHandler() {
+session.subscribe("foo", new MsgHandler() {
public void execute(String msg) {
System.out.println("Received a message: " + msg);
}
});
// Unsubscribing
-Integer sid = session.subscribe("foo", session.new EventHandler() {
+Integer sid = session.subscribe("foo", new MsgHandler() {
public void execute(String msg) {
System.out.println("Received a message: " + msg);
}
});
session.unsubscribe(sid);
// Requests
-sid = session.request("help", session.new EventHandler() {
+sid = session.request("help", new MsgHandler() {
public void execute(String response) {
System.out.println("Got a response for help : " + reponse);
}
});
// Replies
-session.subscribe("help", session.new RequestEventHandler() {
+session.subscribe("help", new MsgHandler() {
public void execute(String request, String replyTo) {
try {
session.publish(replyTo, "I can help!");
@@ -57,27 +57,27 @@ session.stop();
```javascript
// "*" matches any token, at any level of the subject.
-session.subscribe("foo.*.baz", session.new EventHandler() {
+session.subscribe("foo.*.baz", new MsgHandler() {
public void execute(String msg, String reply, String subject) {
System.out.println("Received a message on [" + subject + "] : " + msg);
}
});
-session.subscribe("foo.bar.*", session.new EventHandler() {
+session.subscribe("foo.bar.*", new MsgHandler() {
public void execute(String msg, String reply, String subject) {
System.out.println("Received a message on [" + subject + "] : " + msg);
}
});
-session.subscribe("*.bar.*", session.new EventHandler() {
+session.subscribe("*.bar.*", new MsgHandler() {
public void execute(String msg, String reply, String subject) {
System.out.println("Received a message on [" + subject + "] : " + msg);
}
});
// ">" matches any length of the tail of a subject, and can only be the last token
// E.g. 'foo.>' will match 'foo.bar', 'foo.bar.baz', 'foo.foo.bar.bax.22'
-session.subscribe("foo.>", session.new EventHandler() {
+session.subscribe("foo.>", new MsgHandler() {
public void execute(String msg, String reply, String subject) {
System.out.println("Received a message on [" + subject + "] : " + msg);
}
@@ -93,7 +93,7 @@ session.subscribe("foo.>", session.new EventHandler() {
// Normal subscribers will continue to work as expected.
Properties opt = new Properties();
opt.setProperty("queue", "job.workers");
-session.subscribe(args[0], opt, session.new EventHandler() {
+session.subscribe(args[0], opt, new MsgHandler() {
public void execute(String msg) {
System.out.println("Received update : " + msg);
}
@@ -104,20 +104,20 @@ session.subscribe(args[0], opt, session.new EventHandler() {
```javascript
// Publish with closure, callback fires when server has processed the message
-session.publish("foo", "You done?", session.new EventHandler() {
+session.publish("foo", "You done?", new MsgHandler() {
public void execute() {
System.out.println("Message processed!");
}
});
// Timeouts for subscriptions
-Integer sid = session.subscribe("foo", session.new EventHandler() {
+Integer sid = session.subscribe("foo", new MsgHandler() {
int received = 0;
public void execute() {
received++;
}
});
-session.timeout(sid, TIMEOUT_IN_SECS, session.new EventHandler() {
+session.timeout(sid, TIMEOUT_IN_SECS, new MsgHandler() {
public void execute() {
timeout_recv = true;
}
@@ -126,7 +126,7 @@ session.timeout(sid, TIMEOUT_IN_SECS, session.new EventHandler() {
// Timeout unless a certain number of messages have been received
Properties opt = new Properties();
opt.put("expected", new Integer(2));
-session.timeout(sid, 10, opt, session.new EventHandler() {
+session.timeout(sid, 10, opt, new MsgHandler() {
public void execute(Object o) {
timeout_recv = true;
}
@@ -136,15 +136,15 @@ session.timeout(sid, 10, opt, session.new EventHandler() {
session.unsubscribe(sid, MAX_WANTED)
// Multiple connections
-session1.subscribe("test", session.new EventHandler() {
+session1.subscribe("test", new MsgHandler() {
public void execute(String msg) {
System.out.println("received : " + msg);
}
});
// Form second connection to send message on
Session session2 = Session.connect(new Properties());
-session2.start(session2.new EventHandler() {
+session2.start(new MsgHandler() {
public void execute(Object o) {
Session session = (Session)o;
try {
@@ -1,8 +1,8 @@
-package nats.benchmark;
+package org.nats.benchmark;
import java.util.Properties;
-import nats.Session;
-import nats.Session.EventHandler;
+
+import org.nats.*;
public class PubPerf {
@@ -13,26 +13,27 @@ public static void main(String[] args) throws Exception {
String val = "";
for(int l = 0; l < size; l++) val+="a";
- Session session = Session.connect(new Properties());
+ Properties prop = new Properties();
+ Session session = Session.connect(prop);
session.start();
System.out.println("Performing Publish performance test");
final long start = System.nanoTime();
for(int i = 1; i <= loop; i++) {
- // session.publish("hello", null, new Integer(i).toString(), null);
session.publish("hello", null, val, null);
+ // session.publish("hello", null, new Integer(i).toString(), null);
if (i % hash == 0)
System.out.print("+");
}
- session.flush(session.new EventHandler() {
+ session.flush(new MsgHandler() {
public void execute(Object o) {
double elapsed = System.nanoTime() - start;
System.out.println("\nelapsed : " + Double.toString(elapsed / 1000000000) + " seconds");
System.out.println("msg/sec : " + Double.toString(loop / (elapsed / 1000000000)));
}
});
-
+
session.stop();
System.exit(0);
}
@@ -1,8 +1,9 @@
-package nats.benchmark;
+package org.nats.benchmark;
+import java.io.IOException;
import java.util.Properties;
-import nats.Session;
-import nats.Session.EventHandler;
+
+import org.nats.*;
public class PubSubPerf {
@@ -21,7 +22,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Performing Publish/Subscribe performance test");
final long start = System.nanoTime();
- session1.subscribe("test", session1.new EventHandler() {
+ session1.subscribe("test", new MsgHandler() {
int received = 0;
public void execute(Object o) {
received++;
@@ -38,19 +39,18 @@ public void execute(Object o) {
}
});
- session1.flush(session1.new EventHandler() {
+ session1.flush(new MsgHandler() {
public void execute(Object o) {
- for(int i = 1; i <= loop; i++) {
- try {
+ try {
+ for(int i = 1; i <= loop; i++) {
session2.publish("test", val);
// session2.publish("test", "aaaa\r\nbbbb\r\ncccc\r\ndddd\r\n");
+ // session2.publish("test", new Integer(i).toString());
if (i % hash == 0)
System.out.print("+");
}
- catch(Exception e) {
- e.printStackTrace();
- }
- }
+ session2.flush();
+ } catch(Exception e) {e.printStackTrace();}
}
});
}
View
@@ -1,9 +1,6 @@
-SET PATH="C:\Program Files\Java\jre6\bin"
-REM SET PATH="C:\Program Files\Java\jdk1.7.0_04\bin"
+SET PATH="C:\Program Files\Java\jdk1.7.0_04\bin"
SET CLASSPATH=.
-REM java -ms128m -mx128m nats.benchmark.PubPerf
-java -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -ms512m -mx512m nats.benchmark.PubPerf 500000 16
-REM java -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -ms128m -mx128m nats.benchmark.PubPerf
+java -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -ms512m -mx512m nats.benchmark.PubPerf 100000 1024
-REM pause
+pause
View
@@ -2,16 +2,28 @@
<!-- NewPage -->
<html lang="en">
<head>
-<!-- Generated by javadoc (version 1.7.0_04) on Tue Aug 21 10:59:06 JST 2012 -->
+<!-- Generated by javadoc (version 1.7.0_04) on Fri Aug 31 19:22:48 JST 2012 -->
<title>All Classes</title>
-<meta name="date" content="2012-08-21">
+<meta name="date" content="2012-08-31">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<h1 class="bar">All Classes</h1>
<div class="indexContainer">
<ul>
-<li><a href="nats/Session.html" title="class in nats" target="classFrame">Session</a></li>
+<li><a href="org/nats/examples/AutoUnsub.html" title="class in org.nats.examples" target="classFrame">AutoUnsub</a></li>
+<li><a href="org/nats/examples/Expected.html" title="class in org.nats.examples" target="classFrame">Expected</a></li>
+<li><a href="org/nats/MsgHandler.html" title="class in org.nats" target="classFrame">MsgHandler</a></li>
+<li><a href="org/nats/examples/MultiConnection.html" title="class in org.nats.examples" target="classFrame">MultiConnection</a></li>
+<li><a href="org/nats/examples/Pub.html" title="class in org.nats.examples" target="classFrame">Pub</a></li>
+<li><a href="org/nats/benchmark/PubPerf.html" title="class in org.nats.benchmark" target="classFrame">PubPerf</a></li>
+<li><a href="org/nats/benchmark/PubSubPerf.html" title="class in org.nats.benchmark" target="classFrame">PubSubPerf</a></li>
+<li><a href="org/nats/examples/QueueSub.html" title="class in org.nats.examples" target="classFrame">QueueSub</a></li>
+<li><a href="org/nats/examples/Request.html" title="class in org.nats.examples" target="classFrame">Request</a></li>
+<li><a href="org/nats/Session.html" title="class in org.nats" target="classFrame">Session</a></li>
+<li><a href="org/nats/examples/Sub.html" title="class in org.nats.examples" target="classFrame">Sub</a></li>
+<li><a href="org/nats/examples/SubTimeout.html" title="class in org.nats.examples" target="classFrame">SubTimeout</a></li>
+<li><a href="org/nats/examples/SubUnsub.html" title="class in org.nats.examples" target="classFrame">SubUnsub</a></li>
</ul>
</div>
</body>
@@ -2,16 +2,28 @@
<!-- NewPage -->
<html lang="en">
<head>
-<!-- Generated by javadoc (version 1.7.0_04) on Tue Aug 21 10:59:06 JST 2012 -->
+<!-- Generated by javadoc (version 1.7.0_04) on Fri Aug 31 19:22:48 JST 2012 -->
<title>All Classes</title>
-<meta name="date" content="2012-08-21">
+<meta name="date" content="2012-08-31">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<h1 class="bar">All Classes</h1>
<div class="indexContainer">
<ul>
-<li><a href="nats/Session.html" title="class in nats">Session</a></li>
+<li><a href="org/nats/examples/AutoUnsub.html" title="class in org.nats.examples">AutoUnsub</a></li>
+<li><a href="org/nats/examples/Expected.html" title="class in org.nats.examples">Expected</a></li>
+<li><a href="org/nats/MsgHandler.html" title="class in org.nats">MsgHandler</a></li>
+<li><a href="org/nats/examples/MultiConnection.html" title="class in org.nats.examples">MultiConnection</a></li>
+<li><a href="org/nats/examples/Pub.html" title="class in org.nats.examples">Pub</a></li>
+<li><a href="org/nats/benchmark/PubPerf.html" title="class in org.nats.benchmark">PubPerf</a></li>
+<li><a href="org/nats/benchmark/PubSubPerf.html" title="class in org.nats.benchmark">PubSubPerf</a></li>
+<li><a href="org/nats/examples/QueueSub.html" title="class in org.nats.examples">QueueSub</a></li>
+<li><a href="org/nats/examples/Request.html" title="class in org.nats.examples">Request</a></li>
+<li><a href="org/nats/Session.html" title="class in org.nats">Session</a></li>
+<li><a href="org/nats/examples/Sub.html" title="class in org.nats.examples">Sub</a></li>
+<li><a href="org/nats/examples/SubTimeout.html" title="class in org.nats.examples">SubTimeout</a></li>
+<li><a href="org/nats/examples/SubUnsub.html" title="class in org.nats.examples">SubUnsub</a></li>
</ul>
</div>
</body>
Oops, something went wrong.

0 comments on commit 03e289b

Please sign in to comment.