Can't get reply from queue

Hi Everyone,
I'm trying to implement a messaging service with JMS, using glassfish v2.x as my queuing server.
I have created a requester class (sending messages and waiting for reply) and a replier class (receive messages and reply). I've also configured one connectionFactory, and 2 queues (one for request and one for reply) in glassfish.
Currently I can send a message the replier gets it and replies however the requester is unable to get the reply. The requester uses a synchronous receiver so it just blocks at the receive() method. I'm sure that I have the relevant queues and correlation ids right, but the requester just still can't find any replies.
Any help on this will be greatly appreciated.
How I call the requester
public class MsgBoxProducer {
    public static void main(String[] args) throws Exception{
        String REQ_CONN = "jms/Warehouse_connection";
        String REQ_QUEUE = "jms/Warehouse_Request_Queue";
        String RPLY_QUEUE = "jms/Warehouse_Reply_Queue";
        Requestor requestor = new Requestor(REQ_CONN,REQ_QUEUE,RPLY_QUEUE);
        try{
            for (int i = 0; i < 1; i++) {
                String msg = "Delivery:message" + (i + 1);
                System.out.println("Sending message: " + msg);
                requestor.sendMessage(msg);
                String reply = requestor.receiveReply();
                System.out.println("Received reply: " + reply);
                Thread.sleep(10);
        }finally{
            requestor.closeConn();
        System.exit(0);
}How I call the Replier
public class Warehouse {  
    public static void main(String[] args) throws Exception{
        String REQ_CONN  = "jms/Warehouse_connection";
        String REQ_QUEUE = "jms/Warehouse_Request_Queue";
        Replier replier = new Replier(REQ_CONN,REQ_QUEUE);
        replier.startReplier();
        Reader inputStreamReader = new InputStreamReader(System.in);
        System.out.println("To stop Warehouse application enter: Q/q");
        char answer = 0;
        while (!((answer == 'q') || (answer == 'Q'))) {
            try {
                answer = (char) inputStreamReader.read();
            } catch (IOException e) {
                System.err.println("I/O exception: " + e.toString());
        replier.stopReplier();
        System.exit(0);     
}The replier class, I've omitted open and close methods
public class Replier implements MessageListener {
    private Connection conn;
    private Session session;
    private MessageConsumer requestConsumer;
    private Destination requestQueue;
    public Replier (String confacName, String requestQueueName) {
        try {
            // Connector class just implements some get initial context methods
            Connector connector = new Connector();
            ConnectionFactory confac = connector.getConnectionFactory(confacName);
            conn = confac.createConnection();
            requestQueue = connector.getQueue(requestQueueName);
            session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
            requestConsumer = session.createConsumer(requestQueue);
        catch (Throwable t) {
            System.out.println("Cannot establish replier connection: " + t.getMessage());
    public void onMessage(Message message) {
        try {
            if (message instanceof TextMessage) {
                TextMessage requestMessage = (TextMessage) message;
                String reply = processMessage(requestMessage.getText());
                if (message.getJMSReplyTo() != null) {
                    Destination replyDestination = message.getJMSReplyTo();
                    MessageProducer replyProducer = session.createProducer(replyDestination);
                    TextMessage replyMessage = session.createTextMessage();
                    replyMessage.setText(reply);
                    replyMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());
                    replyProducer.send(replyMessage);
                else {
                    System.out.println("Reply not required");
            else {
                System.out.println("Invalid message detected");
        } catch (JMSException e) {
                e.printStackTrace();
}The Requester class
public class Requestor {
    private Connection conn;
    private Destination reply_dest;
    private Session sess;
    private MessageProducer prod;
    private MessageConsumer consum;
    public Requestor (String confacName, String requestQueueName, String replyQueueName) {
        try {
            Connector connector = new Connector();
            ConnectionFactory cxn = connector.getConnectionFactory(confacName);
            Destination dest = connector.getQueue(requestQueueName);
            reply_dest = connector.getQueue(replyQueueName);
            conn = cxn.createConnection();
            sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
            prod = sess.createProducer(dest);
            consum = sess.createConsumer(reply_dest);
        catch (JMSException e) {
            System.out.println("cannot start connection: "+e.getMessage());
        catch (Throwable t) {
            System.out.println("cannot start connection: "+t.getMessage());
    public void sendMessage(String msg) {
        try {
            TextMessage message = sess.createTextMessage();
            message.setText(msg);
            message.setJMSReplyTo(reply_dest);
            prod.send(message);
        catch (JMSException e) {
            System.out.println("Failed to send message: " + e.getMessage());
    public String receiveReply() {
        String reply = null;
        try {
            Message msg = consum.receive();
            if (msg instanceof TextMessage) {
                TextMessage replyMessage = (TextMessage) msg;
                reply = replyMessage.getText();
            else if (msg == null) {
                System.out.println("Receive timeout");
            else {
                System.out.println("Non text message detected, discard");
        catch (JMSException e) {
            System.out.println("Failed to receive reply: " + e.getMessage());
        finally {
            return reply;
}Edited by: JoyceYu on May 9, 2010 10:32 PM
Edited by: JoyceYu on May 9, 2010 10:38 PM

Yes, I called it in the Warehouse class which is acting as the replier.
What I can see now is that the replier replied and has put the reply message in the reply queue,
but the requester can't see the reply.
I'm just wondering if the receive() function only picks up messages that have the correct correlation ID or does it pick up any replies?
Could that have impacted the receive() function?
public class Warehouse {  
    public static void main(String[] args) throws Exception{
        String REQ_CONN  = "jms/Warehouse_connection";
        String REQ_QUEUE = "jms/Warehouse_Request_Queue";
        Replier replier = new Replier(REQ_CONN,REQ_QUEUE);
        replier.startReplier(); // <----------------------------- called here
  The startReplier function is like this
     public void startReplier() {
        MessageListener listener = this;
        try {
            requestConsumer.setMessageListener(listener);
            conn.start();
        catch (JMSException e) {
            System.out.println("Failed to start replier: " + e.getMessage());
    }Edited by: JoyceYu on May 10, 2010 3:54 PM
Edited by: JoyceYu on May 10, 2010 3:56 PM

Similar Messages

  • How can i get contacts from my old Nokia phone to iphone 4S

    how can i get contacts from my old Nokia phone to iphone 4S?

    Appreciate the reply thank you
    Issue being is I don't have the lead for the samsung any longer but have the memory card?
    An yes I know I need to get them onto my MAC but how is what i'm struggling with?
    Any help would be appreciated.
    Many thanks

  • Can we get data from business views  in CR 2008/XI?

    Hi All,
    Can we get data from business views  in CR 2008/XI?
    If its possible, pls let us know how to get connect with Business View in both of these versions and what is the tool that we have to use to create Business Views.
    Thank you,
    Krishna Pingali

    Hi Krishna,
    Crystal Reports/BusinessObjects Enterprise ( BOE ) Business Views can only be created using the BV build which comes with BOE and installed using the Work Station installer for BOE. for both XI and 2008.
    You cannot mix these two versions on the same PC not can one talk to the other, the BV designer must match the same version as BOE. XI ( version 11.0 ) is no longer available but if you mean XI R2 ( version 11.5 ) then it still is.
    It's not completely clear which Business View you are referring to? BOE has a Business View Designer so not sure if this is just a naming problem or not? If you are referring to the BOE Business View Designer then the above is true. If your reference is about some other BV designer or data source then you need to clarify.
    Contact our Sales department for pricing and availability.
    Thank you
    Don

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • HT203167 lost my hard drive how can i get songs from ipod back to new computer

    I lost my hard drive and want to get my music back on my new computer. How can I get songs from my ipod to my computer? I am afraid to sync it and losing what is on my ipod. Any help would be appreciated.

    It has always been very basic to always maintain a backup copy of your computer for this very occasion.
    Use your backup copy to put everything back.
    If for some reason you have failed to maintain a backup, not good, then you can transfer itunes purchases from your ipod:  File>Transfer Purchases

  • How can I get Data from the Sound cart in Labview? Does a VI exist?

    How can I get Data from the Sound cart in Labview? Does a VI exist?

    Yes, there are VIs for acquiring data from Sound cards. And examples too. If you don't have LabVIEW yet, do a search on NI's site for example VIs.
    Khalid

  • Can't get playlists from one one computer to another.  Confident Home Sharing is turned on correctly.  Have imac and macbook Air and Lion.  Using smart lists.

    Can't get playlists from one one computer to another.  Confident Home Sharing is turned on correctly.  Have imac and macbook Air and Lion.  Using smart lists.

    Using Ethernet, I am attempting to stream the movies on my computer to my girlfriends computer through iTunes home sharing. I want to watch the movies that are on one computer on another.

  • Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

    Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

    Anybody had an issues with mail since upgrading to mountain lion? Can't get emails from one account, tried deleting and recreating but to no avail. Set up a new user and it works fine. Macbook pro 13" mid 2010 model.

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • How can I get music from old mac to new mac?

    How can I get music from old mac to new mac please?
    Can't seem to make Migration Assistant work. Doesn't ask about or transfer files.

    I just migrated into a new MBP from an old one.
    It did not bring the music over.  Apple's instructions are to use the Home Sharing feature of iTunes.
    Open iTunes on your old Mac.  Select Home Sharing under the Advanced menu.  Sign in.  Do the same on your new computer.  Then when the library appears under Home Sharing on the left-hand panel on your new computer's iTunes, you can select all and Add To Library.
    That's what Apple says, anyway.

  • How can I get sound from tv or stereo when watching netflix on MacBook Air?

    I have my macbook air hooked up to my tv and want to watch netflix but the only sound is from my macbook.  How can I get sound from other sources ie tv or stereo?

    Check with Netflix for their system requirements.

  • Can I get warrantee from apple store on my iphone that was bought from Apple in China?

    Can I get warrantee from apple store on my iphone that was bought from Apple in China?  It's still under warrantee, and it's unlocked version. May I get another unlocked one if the phone has to be replaced?

    See Here...
    iTunes: How to move your music to a new computer
    Or...
    From your OLD computer...
    Copy your ENTIRE iTunes FOLDER to an External Drive... and then from the External Drive to your New Computer..
    See Here  >  Move iTunes Library from PC to MAC
    http://www.macworld.com/article/146958/2010/03/move_itunes_windows_mac.html
    Also... Have a look at these 2 Videos...
    http://macmost.com/moving-your-itunes-library.html
    http://macmost.com/moving-your-itunes-media-to-an-external-drive.html

  • How can i get data from a maintance view?

    Hi all.
        Can you give me some suggestion about 'How can i get data from a maintance view?'?
         Thanks
         Best regard

    hi
    good
    go through this link
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ecdf446011d189700000e8322d00/content.htm
    thanks
    mrutyun^

  • Hi, just updated hubby's iPhone 4 and all of his music has disappeared from the iPhone and from the iTunes library! He does have music still stored on his iPod, but can't get it from the library on his iPod back to phone or itunes. technophobe help pls!

    and all of his music has disappeared from the iPhone and from the iTunes library! Luckily he does have music still stored on his iPod, but I can't get it from the library on his iPod back to the phone or to itunes.Please help, but technophobe so put it in simple english please!

    Sounds like the music you had on your phone was not the same music on his computer. The iPhone/iPod touch is not designed to be a storage device. When you sync with a computer that doesn't have your music, it deletes your music from your phone.
    Was this music you purchased from iTunes? if so, and you are in the US, tap on itunes app, tap updates, tap purchased and tap on the cloud icon to get each song back. If you're not int he us, get iOS5 update later this week and do the same.
    But you need to move your itunes library to his computer. Create a user account on his macbook pro for you. From your external drive backup, load your itunes library on it. Then sync as usual! (Don't tell me you don't have a backup for your computer!)

  • How can you get pics from your Camera roll to you photo stream

    How can you get pics from your Camera roll to you photo stream

    iCloud: Photo Stream FAQ
    iCloud: Photo Stream
    iCloud: Set up Photo Stream

Maybe you are looking for

  • Why can't I log into iCloud on my iPad?

    When I go to the iCloud.com website on my iPad, I can't log into my iCloud account. The only options are to (a) set up iCloud, which has already been set up on all my devices, (b) Install Find My Phone, which is already installed on my iPad, or (c) I

  • Camera connector, nikon 3200, 0 pictures

    I have a fifth generation video ipod, 30 GB, software version 1.1.2 and tried syncing pictures from my Nikon 3200 using the camera connector. It has worked fine for two imports of a few (50) pictures but on the third import, it seemed to stop during

  • Background image for Live Broadcasting

    I want to have a background behind me when I broadcast live video.  I was going to buy something to physically place behind me and I wnat to know if I can create or use a template image using visual communicator  or some other software.  Thanks in ad

  • Firefox doesn't bring information to a Reply or Replay All screen

    When I want to reply to a single person or group of people I click the reply or reply all boxes. This has worked fine until a few weeks ago. Since then I was able to go thru the routine a couple of times and then it would bring the contents with it.

  • Filter for Safari

    I teach web design at the high school level and I'm have a little trouble keeping a small group of students focused on their work when myspace, e-mail and youtube are just a click away. I'm looking for a mac application that will allow my students to