MessageBrokerServlet 初始化问题 - 将数据从 java 推送到 Flex 应用程序

发布于 2024-12-28 23:48:30 字数 12781 浏览 2 评论 0原文

大家好

我正在研究从 Java 到 Flex 的服务器推送。但是 MessageBrokerServlet 没有被初始化的一些原因,似乎是从以下位置调用一个方法:

flex.messaging.config.LoginCommandSettings.setMatch()

最终我发现该方法确实不存在于该类中(LoginCommandSettings)。我还有其他问题吗?

这就是 tomcat 日志的内容:

2012-01-24 14:04:57 StandardContext[/mywebapp]StandardWrapper.Throwable
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)

2012-01-24 14:04:57 StandardWrapperValve[MessageBrokerServlet]: Allocate exception for servlet MessageBrokerServlet
javax.servlet.ServletException: Servlet.init() for servlet MessageBrokerServlet threw exception
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1071)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
—– Root Cause —–
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)

我是 Flex 编程新手,并且使用 tomcat server- jakarta-tomcat-5.0.28 来部署 Web 应用程序。我已经对 messaging-config.xmlservices-config.xml 进行了所有更改,并编写了一个带有线程的 Java 类来不断推送数据。

我在我的java代码中使用了2个库:

  1. blazeds-common-3.0

  2. flex-messaging

自从过去两天以来我一直坚持这个。 .. 因此,在这方面的任何帮助将不胜感激......

提前致谢!

-Adwait

这是我的 messages-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" 
    class="flex.messaging.services.MessageService">

    <adapters>
        <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
        <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
        <adapter-definition id="feed" class="packagename.className"/>
    </adapters>
    <destination id="feed">
        <properties>
            <network>
                <session-timeout>0</session-timeout>
            </network>
            <server>
                <max-cache-size>1000</max-cache-size>
                <message-time-to-live>0</message-time-to-live>
                <durable>false</durable>
            </server>
        </properties>
        <channels>
            <channel ref="my-rtmp"/>
        </channels>
    </destination>
</service>

这是我的 AS 文件:

import mx.messaging.Consumer;
import mx.messaging.events.MessageEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.IMessage;

private var listner: Consumer;

// functio to handle the creationComplete event:
public function ccHandler(): void {

    listner = new Consumer();
    listner.addEventListener(MessageEvent.MESSAGE, onReceiveMessageFromServer);
    listner.addEventListener(MessageFaultEvent.FAULT, onFailedReceiveMessageFromServer);
}

// receive message handler:
private function onReceiveMessageFromServer(message: IMessage): void {

    lblMessageReceivedFromServer.text = message.body.toString();
}

// fault message handler:
private function onFailedReceiveMessageFromServer(message: IMessage): void {

    lblMessageReceivedFromServer.text = "Error when receiving message from 'feed'";
}

定期发送数据的 Java 类(目标):

import flex.messaging.MessageBroker;
import flex.messaging.messages.AsyncMessage;
import flex.messaging.messages.Message;
import flex.messaging.services.ServiceAdapter;
import flex.messaging.util.UUIDUtils;

/**
 *
 * @author adeshpande
 */
public class ServerPushManager extends ServiceAdapter {

    private volatile boolean running;

    public static void sendMessageToClients() {

        // random no. to send to client:
        double dNumber = 0;

        // set the message broker 
        final MessageBroker msgBroker = MessageBroker.getMessageBroker(null);

        // set the UUID:
        final String clientId = UUIDUtils.createUUID(false);

        // create the message to send and set parameters
        final AsyncMessage msg = new AsyncMessage();
        msg.setDestination("feed");
        msg.setClientId(clientId);
        msg.setMessageId((UUIDUtils.createUUID(false)));
        msg.setTimestamp(System.currentTimeMillis());
        dNumber = Math.random()*100;
        msg.setBody(dNumber);
        System.out.println("\n---- Message to send: " +dNumber +" ----\n");

        // send the message into the message routing system:
        msgBroker.routeMessageToService(msg, null);
    }

    /*
    private void sendMessageToClients(Message msg) {

        ((MessageService) getDestination().getService()).pushMessageToClients(msg, false);
    }
    */


    @Override                  // flex.messaging.services.ServiceAdapter ---> start()
    public void start(){

        super.start();
        Thread messageSender = new Thread(){

            @Override
            public void run(){

                running = true;
                while(running){

                    sendMessageToClients();
                    secondsToSleep(3);
                }
            }
        };
        messageSender.start();        
    }


    @Override                   // flex.messaging.services.ServiceAdapter ---> stop()
    public void stop(){

        super.stop();
        running = false;
    }



    @Override
    public Object invoke(Message message) {

        if (message.getBody().equals("stop")) {

            running = false;
        }
        return null;
    }

    private void secondsToSleep(int seconds) {

        try{

            Thread.sleep(seconds * 1000);
        }
        catch(InterruptedException e){

            System.out.println("TestServiceAdapter Interrupted while sending messages");
            e.printStackTrace();
        }
    }
}

Hi All,

I am working on a server push from Java to Flex. But some how the MessageBrokerServlet is not getting initialized, seems like it is calling a method from:

flex.messaging.config.LoginCommandSettings.setMatch()

Eventually I found out that this method indeed does not exist in that class (LoginCommandSettings). I there something else that is going wrong ?

This is what the tomcat log says:

2012-01-24 14:04:57 StandardContext[/mywebapp]StandardWrapper.Throwable
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)

2012-01-24 14:04:57 StandardWrapperValve[MessageBrokerServlet]: Allocate exception for servlet MessageBrokerServlet
javax.servlet.ServletException: Servlet.init() for servlet MessageBrokerServlet threw exception
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1071)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
—– Root Cause —–
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)

I am new to flex programming and using tomcat server- jakarta-tomcat-5.0.28 for deploying the web-app. I have made all the changes to messaging-config.xml, services-config.xml and written a Java class with a thread to keep pushing the data.

I have used 2 libraries in my java code:

  1. blazeds-common-3.0

  2. flex-messaging

I am stuck with this since last 2 days...
So any help in this context would be greatly appreciated...

Thanks in Advance !!

-Adwait

This is my messaging-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" 
    class="flex.messaging.services.MessageService">

    <adapters>
        <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
        <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
        <adapter-definition id="feed" class="packagename.className"/>
    </adapters>
    <destination id="feed">
        <properties>
            <network>
                <session-timeout>0</session-timeout>
            </network>
            <server>
                <max-cache-size>1000</max-cache-size>
                <message-time-to-live>0</message-time-to-live>
                <durable>false</durable>
            </server>
        </properties>
        <channels>
            <channel ref="my-rtmp"/>
        </channels>
    </destination>
</service>

And this is my AS file:

import mx.messaging.Consumer;
import mx.messaging.events.MessageEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.IMessage;

private var listner: Consumer;

// functio to handle the creationComplete event:
public function ccHandler(): void {

    listner = new Consumer();
    listner.addEventListener(MessageEvent.MESSAGE, onReceiveMessageFromServer);
    listner.addEventListener(MessageFaultEvent.FAULT, onFailedReceiveMessageFromServer);
}

// receive message handler:
private function onReceiveMessageFromServer(message: IMessage): void {

    lblMessageReceivedFromServer.text = message.body.toString();
}

// fault message handler:
private function onFailedReceiveMessageFromServer(message: IMessage): void {

    lblMessageReceivedFromServer.text = "Error when receiving message from 'feed'";
}

Java class (destination) to send data at regular intervals:

import flex.messaging.MessageBroker;
import flex.messaging.messages.AsyncMessage;
import flex.messaging.messages.Message;
import flex.messaging.services.ServiceAdapter;
import flex.messaging.util.UUIDUtils;

/**
 *
 * @author adeshpande
 */
public class ServerPushManager extends ServiceAdapter {

    private volatile boolean running;

    public static void sendMessageToClients() {

        // random no. to send to client:
        double dNumber = 0;

        // set the message broker 
        final MessageBroker msgBroker = MessageBroker.getMessageBroker(null);

        // set the UUID:
        final String clientId = UUIDUtils.createUUID(false);

        // create the message to send and set parameters
        final AsyncMessage msg = new AsyncMessage();
        msg.setDestination("feed");
        msg.setClientId(clientId);
        msg.setMessageId((UUIDUtils.createUUID(false)));
        msg.setTimestamp(System.currentTimeMillis());
        dNumber = Math.random()*100;
        msg.setBody(dNumber);
        System.out.println("\n---- Message to send: " +dNumber +" ----\n");

        // send the message into the message routing system:
        msgBroker.routeMessageToService(msg, null);
    }

    /*
    private void sendMessageToClients(Message msg) {

        ((MessageService) getDestination().getService()).pushMessageToClients(msg, false);
    }
    */


    @Override                  // flex.messaging.services.ServiceAdapter ---> start()
    public void start(){

        super.start();
        Thread messageSender = new Thread(){

            @Override
            public void run(){

                running = true;
                while(running){

                    sendMessageToClients();
                    secondsToSleep(3);
                }
            }
        };
        messageSender.start();        
    }


    @Override                   // flex.messaging.services.ServiceAdapter ---> stop()
    public void stop(){

        super.stop();
        running = false;
    }



    @Override
    public Object invoke(Message message) {

        if (message.getBody().equals("stop")) {

            running = false;
        }
        return null;
    }

    private void secondsToSleep(int seconds) {

        try{

            Thread.sleep(seconds * 1000);
        }
        catch(InterruptedException e){

            System.out.println("TestServiceAdapter Interrupted while sending messages");
            e.printStackTrace();
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栀子花开つ 2025-01-04 23:48:30

AFAIK,RTMP 和 RTMPT 协议仅在 LiveCycle Data Services (LCDS) 中可用,在 BlazeDS 中不可用,这解释了这些错误。

AFAIK, the RTMP and RTMPT protocols are only available in LiveCycle Data Services (LCDS), not BlazeDS, which explains the errors.

我的鱼塘能养鲲 2025-01-04 23:48:30

听起来你的 blaze 设置有问题。找到问题可能会很困难。相反,尝试使用 BlazeDS 进行全新的工作。您可以尝试以下简单的 2 分钟设置:

  • 在 tomcat 上安装 blazeDS
  • 制作 webapps/blazeds 的副本,并将该副本重命名为您的应用程序名称
  • 现在将您编码的所有 java 类添加到 webapps/my-application/WEB- INF/classes 文件夹
  • 配置 WEB-INF/flex/remoting-config 和 services-config.xml 文件

这样您就可以确保所有依赖的库、类和配置文件都包含在您的应用程序中。

It sounds like there is something wrong with your blaze setup. Finding the problem might be difficult. Instead, try to work of a clean slate of BlazeDS. Here's a simple 2 minute setup you can try:

  • Install blazeDS on tomcat
  • Make a copy of webapps/blazeds, and rename the copy to whatever you called your application
  • Now add all the java classes you coded to the webapps/my-application/WEB-INF/classes folder
  • Configure WEB-INF/flex/remoting-config and services-config.xml files

This way you will be sure that all the dependent libs, classes and config files are included in your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文