Web服务连接到远程队列

时间:2013-03-30 17:18:54

标签: web-services

我正在开发一个托管在JBoss 4.2.3服务器内的Web服务解决方案(如下所示),我的代码连接到远程JMS队列帽托管在另一台服务器上(192.168.35.25)

 public static Context getInitialContext () throws JMSException,NamingException
    {
        Properties prop = new Properties();
        prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        prop.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
        prop.setProperty("java.naming.provider.url", "192.168.35.20:1099");
        Context context = new InitialContext(prop);

        return context;

}

 public String SendMessages(String msg) throws ServletException, IOException, URISyntaxException {
    String body="";
    try
    {

        Context init =ClsSat.getInitialContext();
        javax.jms.Queue destination = (javax.jms.Queue) init.lookup("Queue/RemoteQueue");

          ConnectionFactory connectionFactory =   (ConnectionFactory) init.lookup("ConnectionFactory");
          Connection connection = connectionFactory.createConnection("un","pwd");//
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

;

          MessageProducer producer = session.createProducer(destination);


          TextMessage message = session.createTextMessage();
          message.setText(msg);

          connection.start();

          producer.send(message);
          body = message.getText();


          session.close();
          connection.close();

      } 
    catch (Exception e)
      {
          return(e.toString());
      }

return body    ;

}

但是我收到了一个错误...... RemoteQueue没有绑定 所以任何人都有关于连接到远程queus throw web服务的想法或帮助 或任何有关从本地计算机上托管的Web服务连接到远程计算机上的远程队列的文档

1 个答案:

答案 0 :(得分:0)

可能是因为你的getInitialContext()中的IP地址错误,请检查一下你是否可以提供更多细节。