其实我的需求很简单,就是怎么通过jms client远程访问sun message queue?

解决方案 »

  1.   

    一般需要put进Context.INITIAL_CONTEXT_FACTORY和Context.PROVIDER_URL属性就可以了
    你上面列举的几个Context.INITIAL_CONTEXT_FACTORY类名,你先要确定你的lib库中是否有这个类.还有Context.PROVIDER_URL里面端口也需要确定那个端口是否打开.具体Sun Application Server用那个类,先要确定你的JMS server是用那个产品的.是Sun Application Server自带的?
      

  2.   

    楼上的兄弟,我测试了不行啊!倒是下面这样写是可以的:
                String host = "10.167.16.201"; //server machine IP
                String port = "3700"; //port
                System.setProperty("org.omg.CORBA.ORBInitialHost", host);
                System.setProperty("org.omg.CORBA.ORBInitialPort", port);
                ctx = new InitialContext();哪位高手能不能详细的讲解一下它们的区别?
      

  3.   

    Properties prop = new Properties(); prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory"); 
    prop.put(Context.PROVIDER_URL,"iiop://localhost:7676"); JndiTemplate jndi = new JndiTemplate(prop); 
    QueueConnectionFactory fabrika = (QueueConnectionFactory) jndi.lookup("qcf");
      

  4.   

    哦,理论上是应该可以的,因为我以前用这种方式连过Jboss自带的jms,也连过IBM的MQ.
    帮楼主顶!
      

  5.   

    To c366oem(zoey) :我用的就是Sun Application Server自带的message queue,但我是在Sun Application Server中配置的ConnectionFactory等。
    本来我是单独安装了sun message queue,但它的example都是本地测试的,我不知道怎么远程测试(远程测试需要jndi server),所以就干脆用Sun Application Server自带的sun message queue
      

  6.   

    to c366oem(zoey) :你上面的写的localhost,而且RefFSContextFactory是文件系统的,好象还需要指定一个目录。如果在另外一台机器运行jms client,肯定是不行了。
      

  7.   

    各位高手,请教2个问题:1:远程的jms client怎么通过SSL进行访问sun message queue?2:大家一般都是怎么集群的?
      

  8.   

    com.sun.messaging.QueueConnectionFactory 类的方法
    setProperty("imqAddressList","10.0.65.11:7676,10.0.65.11:7777");1、这个是直接通过com.sun.messaging.QueueConnectionFactory 创建连接--这个很简单2、也可以采用 com.sun.jndi.fscontext.RefFSContextFactory 文件系统环境工厂来配置一个连接到messagequeue 的环境。然后通过Properties prop = new Properties(); prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory"); 
    prop.put(Context.PROVIDER_URL,"file:///c:/mytest"); 再用jndi 来获取messagequeue  Server上面的 QueueConnectionFactory对象然后通过QueueConnectionFactory 对象来创建连接如何初始化一个绑定的对象文件上下文环境系统呢?
    可以通过sun messagequeue 自带的可执行文件,可以生成这个文件系统环境上下文
    c:/mytest
      

  9.   

    单个 setProperty("imqAddressList","10.0.65.11:7676");
      

  10.   

    其实,你的这些问题,我相信在这里的文档都能告诉你:
    http://docs.sun.com/app/docs/prod/s1msgqu?l=zh#hic
      

  11.   

    Sun产品系列命名太怪了,好多版本,而且一个产品又包含若干个产品。
      

  12.   

    csrcom(泥鳅)兄,你好!你说的用com.sun.jndi.fscontext.RefFSContextFactory 文件系统环境工厂来配置一个连接到messagequeue 的环境,再用jndi 来获取messagequeue  Server上面的 QueueConnectionFactory对象。请教,这种方式能远程通过jndi来获取QueueConnectionFactory吗?
      

  13.   

    首先你要在server端 创建一个 QueueConnectionFactory (用imqobjmgr 工具,只要安装了message queue 就有了)。相关这方面的demo: MessageQueue安装路径下面\demo\imqobjmgr
      

  14.   

    csrcom(泥鳅)兄:
    我是用imqadmin进行了配置,参考http://docs.sun.com/source/819-3561/quick-start.html做的,在本机测试是可以的,但远程就不行。正如上面你写的prop.put(Context.PROVIDER_URL,"file:///c:/mytest"); 这个PROVIDER_URL都指向本地的文件系统,怎么可能支持远程jms client?
      

  15.   

    csrcom(泥鳅)兄:本来我是单独的只安装了sun message queue,但好象要远程的发消息的话,必须要再安装一个jndi server(如:openldap之类的)。是这样的吗?难道sun message queue本身没有jndi服务吗?难道不支持远程发消息吗?我不知道怎么做,请csrcom(泥鳅)兄不吝指教,谢谢!
      

  16.   

    所以我干脆就用Sun Application Server,因为Sun Application Server自带了sun message queue,而且我目前就是通过以下方式来远程发消息的:            String host = "10.167.16.201"; //server machine IP
                String port = "3700"; //port
                System.setProperty("org.omg.CORBA.ORBInitialHost", host);
                System.setProperty("org.omg.CORBA.ORBInitialPort", port);
                ctx = new InitialContext();不知道csrcom(泥鳅)兄是怎么做的?
      

  17.   

    1.使用JNDI查询
     我们以在SUN Java System Application Server 8.1中添加工厂对象为例,将QueueConnectionFactory 对象绑定到jndi tree,并在属性编辑列表中添加属性“AddressList”,其值为 “mq://localhost:7676/, mq://localhost:7686/”.  
    2.直接实例化工厂对象
     import com.sun.messaging.*;
    myQConnFactory = new com.sun.messaging.QueueConnectionFactory();
    myQConnFactory.setProperty(ConnectionConfiguration.imqAddressList, "localhost:7676,localhost:7686");
    myQConnFactory.setProperty(ConnectionConfiguration.imqAddressListBehavior, "RANDOM"); 
    编译运行时,将imqlibjms.jar, imqlibimq.jar 加入到classpath。 
      

  18.   

    csrcom(泥鳅)兄:请继续到下面的链接指导吧,先谢谢了!    http://community.csdn.net/Expert/topic/4854/4854621.xml?temp=.1131555本贴就快要揭贴了,各位高手继续指导啊!