Jmin队列的测试例子

Jmin队列的测试例子:

发送端:

public class TestQueue {

public static void main(String args[])throws Exception{

NSRB nsrb = NSRB.init();
NetContext context = nsrb.createNetContext("socket://localhost:9988");
QueueProxy proxy1 = new QueueProxy();
QueueXMLProxy proxy2 = new QueueXMLProxy();
proxy1.bind(context);
proxy2.bind(context);

AsynRequest request = new AsynRequest();
J2eeAspectDestination destination= new J2eeAspectDestination();
destination.setAspectName("hello");
destination.setServiceID("queue");
request.setDestination(destination);

request.setContent("test1");
proxy1.publish(request);
request.setContent("test2");
proxy2.publish(request);

}


接收端:(尽管发送端有时使用XML序列化传送的数据,一样可以接受;如果接受端不在线的话,信息将保存在队列中!)

public class TestReceiver {

public static void main(String args[])throws Exception{

NSRB nsrb = NSRB.init();
NetContext context = nsrb.createNetContext("socket://localhost:9988");
QueueProxy proxy1 = new QueueProxy();
proxy1.bind(context);

HelloAsynListner lister = new HelloAsynListner();
proxy1.connect("queue","hello",lister);

Object obj = new Object();
Locker.lock(obj);
}

}


简单吧!

平均得分
(0 次评分)





文章来自: 本站原创
标签: jmservice 
评论: 8 | 查看次数: 1424
  • 共有 8 条评论
游客 [2008-11-25 10:56:38]
游客 [2008-09-20 14:50:02]
游客 [2008-09-12 14:41:38]
游客 [2008-09-11 14:30:06]
游客 [2008-09-04 12:59:39]
游客 [2008-09-03 10:44:04]
游客 [2008-08-14 17:29:52]
游客 [2008-04-11 18:00:15]
我是JJ 你写的很好 我很喜欢[handclap][smile]
  • 共有 8 条评论
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启