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

  • SEARCH
  • Home
  • 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 6923861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:35:24+00:00 2026-05-27T10:35:24+00:00

I am new to CometD, Is there any simple example to implement service channel

  • 0

I am new to CometD, Is there any simple example to implement service channel model in case of response/request model. I have seen cometd.org but there is no such example to how to send the response back if i publish to any channel.

This is the client side

alert("channel published1");
    dojox.cometd.publish('/service/getlist');   
    alert("channel published");
    dojox.cometd.subscribe('/service/getlist', function(message) {
        alert(message);
    });

this is server side “ConfigurationServlet”

bayeux.createIfAbsent("/service/getlist", new ConfigurableServerChannel.Initializer() {

        //new EchoService(bayeux);
        @Override
        public void configureChannel(ConfigurableServerChannel channel) {
            /*channel.setPersistent(true);
            GetListChannelListener channelListner = new GetOrderListChannelListener();
            channel.addListener(channelListner);*/
            new EchoService(bayeux);
        }
    });

EchoService

public class EchoService extends AbstractService{
public EchoService(BayeuxServer bayeuxServer)                                 
{
    super(bayeuxServer, "getlist");                                              
    addService("/service/getlist", "processEcho");                                       
}

public void processEcho(ServerSession remote,Map<String, Object> data)
{       
    try{
    System.out.println("Start Process Echo");
    getBayeux().getChannel("/service/getlist").publish(getServerSession(), "Hello", null);
    System.out.println("End Process Echo");
    }catch(Exception exp){
        exp.printStackTrace();
    }
    //remote.deliver(getServerSession(), "/service/getlist", data, null);                  
}

}

  • 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-27T10:35:25+00:00Added an answer on May 27, 2026 at 10:35 am

    On http://cometd.org there is everything you need.

    In order to build a very simple example (web application with Javascript client) you need to read in particular:

    • This for the client side
    • This for the server side (configuration)
    • This for the server side (code). From this menu you may want to start with using the first and third bullet points: Inherited Services for the code that echoes the inputed message, and Server Services Integration for the setup of the Bayeux Server through a configuration servlet.

    In the pages that I have linked there is all the code necessary, just copy and paste it. In case, come back with more specific questions.


    EDITED

    After looking at your code, I see that for the service configuration you need to copy the code for ConfigurationServlet class from here and for the EchoService class you need to modify the processEcho method as follows:

    remote.deliver(getServerSession(), "/echo", data, null);
    

    with data being an HashMap defined as explained here (first example).

    On the client side, I’d subscribe to the channel before publishing your request (I am not sure if it works in your way either)

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

Sidebar

Related Questions

I have a simple comet chat. JavaScript send ajax request with long polling. When
I'm trying to implement simple Comet chat example and for this I implemented Long
I have a Java web application that uses CometD. The workflow is simple: I
New to WCF, but familiar with COM+ - can I wrap a WCF service
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
Does anyone know any system wich work like facebook request, message, notification bubble system?
I currently have a very simple web application written in Django, and I would
New class is a subclass of the original object It needs to be php4
New to javascript/jquery and having a hard time with using this or $(this) to
New to xml. Looking for XPath to search a xml file with python ElementTree

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.