将消息发送到远程JMS队列

时间:2014-12-19 07:22:54

标签: jms weblogic

我在 cluster1_machine1 cluster2_machine2 上部署了一个应用程序。队列位于 cluster1_machine1

使用 cluster1_machine1 中的应用程序可以很好地发送和接收消息,但 cluster2_machine2 中的应用程序无法将消息发送到 cluster1_machine1 中的队列

我继续得到以下异常,我知道由于以下代码而引发异常。

WLSession s = (WLSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

例外:

java.lang.AbstractMethodError: retrieveThreadLocalContext
    at weblogic.messaging.dispatcher.DispatcherProxy.unmarshalResponse(DispatcherProxy.java:243)
    at weblogic.messaging.dispatcher.DispatcherProxy.dispatchSyncTranFuture(DispatcherProxy.java:134)
    at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSyncTran(DispatcherWrapperState.java:334)
    at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSyncNoTran(DispatcherWrapperState.java:381)
    at weblogic.messaging.dispatcher.DispatcherWrapperState.dispatchSync(DispatcherWrapperState.java:249)
    at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSync(DispatcherAdapter.java:43)
    at weblogic.jms.client.JMSConnection.setupJMSSession(JMSConnection.java:529)
    at weblogic.jms.client.JMSConnection.createSessionInternal(JMSConnection.java:497)
    at weblogic.jms.client.JMSConnection.createSession(JMSConnection.java:483)
    at weblogic.jms.client.WLConnectionImpl.createSession(WLConnectionImpl.java:552)
    at jsp_servlet.__enqueue._jspService(__enqueue.java:198)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:327)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3750)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3714)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2283)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2182)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1491)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

请帮忙。谢谢!

生产者代码:

try {
        InitialContext ic = getInitialContext("t3://cluster2_machine2:<PORT>");
        ConnectionFactory qconFactory = (ConnectionFactory) ic.lookup("jms/TestConnectionFactory");
        Connection connection = qconFactory.createQueueConnection();
        WLSession s = (WLSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = (Destination) ic.lookup("jms/TestJMSQueue");
        WLMessageProducer producer = (WLMessageProducer) s.createProducer(null);
        TextMessage msg = s.createTextMessage();
        connection.start();

        msg.setText(strMsg);
        producer.send(queue,msg);

        producer.close();
        s.close();
        connection.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

private static InitialContext getInitialContext(String url)
            throws NamingException {
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
        env.put(Context.PROVIDER_URL, url);
        return new InitialContext(env);
    }

0 个答案:

没有答案