Results 1 to 3 of 3

Thread: to publish a message

  1. #1
    Junior Member
    Join Date
    May 2011
    Answers
    2

    to publish a message

    Hi,
    I've downloaded a .war file from internet that uses Atmosphere framework(Name is JQuery-PubSub).
    Basically, what it does is, it forms chat kind of application.
    i.e. u can create/subscribe to a particular topic. so, whoever posts some data to that topic, all the clients(those who subscribed to that topic) will be notified(Asynchronous concept).

    Now, what i want to do.?
    1. I want to subscribe to a particular topic which is already there.
    2. i want to publish some message(some hard-coded text) using a standalone java program, rather than posting from web browser.
    3. So that, i will open a web-browser and i will subscribe to that topic and verify whether my .java program is able to publish the message.
    4. I tried a program but it didn't work.
    5. can anybody help me.?


    My program:
    package com.myexamples.test;


    import java.net.URI;

    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.UriBuilder;

    import com.sun.jersey.api.client.Client;
    import com.sun.jersey.api.client.ClientResponse;
    import com.sun.jersey.api.client.WebResource;
    import com.sun.jersey.api.client.config.ClientConfig;
    import com.sun.jersey.api.client.config.DefaultClientConfig;
    import com.sun.jersey.core.header.MediaTypes;

    public class Test {
    public static void main(String[] args) {
    ClientConfig config = new DefaultClientConfig();
    Client client = Client.create(config);
    WebResource service = client.resource(getBaseURI());
    //Message i want to publish
    String msg = "This is a test message";
    //Here, i am posting.
    ClientResponse response1 = service.path("pubsub").path("Topic").post(ClientResponse.class, msg);
    System.out.println("Sent Succesfully!");

    }

    private static URI getBaseURI() {
    //Path of web-app, typically localhost:8080/jquery-pubsub/

    }

    }


  2. #2
    Junior Member
    Join Date
    May 2011
    Answers
    2

    Re: to publish a message

    private static URI getBaseURI() {
    //Path of web-app, typically localhost:8080/jquery-pubsub/

    }

    is nothing but, in my case,

    private static URI getBaseURI() {
    return UriBuilder.fromUri("
    localhost:8080/jquery-pubsub/").build();
    }


  3. #3
    Junior Member
    Join Date
    Jun 2011
    Answers
    11

    Re: to publish a message

    @Mani... what is that you exactly what to show us ?


  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact