Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 593159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:48:58+00:00 2026-05-13T15:48:58+00:00

I am using BlazeDS for data-push feature in my Flex application project. From the

  • 0

I am using BlazeDS for data-push feature in my Flex application project. From the official tutorial, Getting started with BlazeDS, it shows messaging example with producer/consumer from API.

but how can I implement server side which doesn’t need to be invoke from Flex client, but from within server-side instead. I got some idea but I don’t know how to do because I’m a Flex developer, not Java developer, so I think you can help me.

  1. In Google, there’s a tutorial show about I need to extend ServiceAdapter class in Java-side, which extends Invoke method. Do I need to extend other class instead of this to do what I want?

  2. How to configure the message-config.xml to get the result like I describe above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:48:58+00:00Added an answer on May 13, 2026 at 3:48 pm

    Here is test code I wrote and use, at times, to test sending data to our client. It’s a stripped down, bare bones Java example of a ServiceAdapter implementation. It removes a lot of unnecessary code from the existing examples on the web. It Compiles, works and I use it often in testing.

    package your.package.structure.adapter;
    
    import your.package.structure.device.DevicePort;
    import flex.messaging.messages.AsyncMessage;
    import flex.messaging.messages.Message;
    import flex.messaging.services.MessageService;
    import flex.messaging.services.ServiceAdapter;
    import flex.messaging.util.UUIDUtils;
    
        /**
         * Test service adapter.  Great for testing when you want to JUST SEND AN OBJECT and nothing
         * else.  This class has to stay in the main codebase (instead of test) because, when it's used
         * it needs to be deployed to Tomcat.
         * @author Kevin G
         *
         */
    
    public class TestServiceAdapter extends ServiceAdapter {
    
        private volatile boolean running;
    
        private Message createTestMessage() {
            DevicePort objectToSend = new DevicePort("RouterDevice");
    
            final AsyncMessage msg = new AsyncMessage();
            msg.setDestination(getClass().getSimpleName() + "Destination");
            msg.setClientId(UUIDUtils.createUUID());
            msg.setMessageId(UUIDUtils.createUUID());
            msg.setBody(objectToSend);
    
            return msg;
        }
    
        private void sendMessageToClients(Message msg) {
            ((MessageService) getDestination().getService()).pushMessageToClients(msg, false);
        }
    
        /**
         * @see flex.messaging.services.ServiceAdapter#start()
         */
        @Override
        public void start(){    
            super.start();
    
            Thread messageSender = new Thread(){
                public void run(){
                    running = true;
                    while(running){
                        sendMessageToClients(createTestMessage());
                        secondsToSleep(3);
                    }
                }
            };
    
            messageSender.start();        
        }
        /**
         * @see flex.messaging.services.ServiceAdapter#stop()
         */
        @Override
        public void stop(){
            super.stop();
            running = false;
        }
        /**
         * This method is called when a producer sends a message to the destination. Currently,
         * we don't care when that happens.
         */
        @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();
            }
        }        
    }
    

    You need to set a few properties in tomcat to get this to work.

    In messaging-config.xml, you need to add an adapter and destination:

    Add this line to the existing <adapters> tag:

     <adapter-definition id="TestServiceAdapter" class="your.package.structure.adapter.TestServiceAdapter"/>
    

    Add this destination to that same messaging-config.xml file:

    <destination id="TestServiceAdapterDestination">
            <channels>
                <channel ref="my-streaming-amf"/>
            </channels>
            <adapter ref="TestServiceAdapter"/>
        </destination>
    

    Finally, make sure the “my-streaming-amf” channel is defined in services-config.xml, as in:

    <channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
            <properties>
                 <!-- you don't need to set all these properties, this is just what we set, included for illustration, only -->
                <idle-timeout-minutes>0</idle-timeout-minutes>
                <max-streaming-clients>10</max-streaming-clients>
                    <server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis>
                <user-agent-settings>
                    <user-agent match-on="Safari" kickstart-bytes="2048" max-streaming-connections-per-session="10"/>  
                    <user-agent match-on="MSIE" kickstart-bytes="2048" max-streaming-connections-per-session="15"/> 
                    <user-agent match-on="Firefox" kickstart-bytes="2048" max-streaming-connections-per-session="10"/>
                </user-agent-settings>
            </properties>
        </channel-definition>
    

    Note that in blazeDS, these two config files (messaging-config.xml and services-config.xml) are located in the following directory:

    /blazeds/tomcat/webapps/[nameOfYourApp]/WEB-INF/flex/
    

    where [nameOfYourApp] is the directory your webapp lives in.

    I hope all that helps!

    -kg

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I using messaging in Flex-BlazeDS. When the AIR client starts it connects to a
When pushing objects from ColdFusion to Flex via BlazeDS, and mapping the classes using
Using JDeveloper , I started developing a set of web pages for a project
I'm using BlazeDS to remote some Java objects that I'm consuming in a Flex
we are using BlazeDS as a proxy between Flex and Java. The approach is
I am using BlazeDS java client to get info from this page . This
Is BlazeDS 4 work with Google App Engine. I'm using BlazeDS 3.2.0 and getting
I'm using Flex 3.5, BlazeDS 3.2.0.3978 and EJB3 for backend. There are two RPC
I'm working on a Flex/BlazeDS/Spring/JPA/Hibernate web application hooked up to a Microsoft SQL Server
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.