/[projects]/miscJava/Test3/src/dk/thoerup/messagedriven/ReverserServlet.java
ViewVC logotype

Diff of /miscJava/Test3/src/dk/thoerup/messagedriven/ReverserServlet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1275 by torben, Thu Apr 7 19:14:32 2011 UTC revision 1276 by torben, Thu Apr 7 19:24:51 2011 UTC
# Line 41  public class ReverserServlet extends Htt Line 41  public class ReverserServlet extends Htt
41                          msg = "Default";                          msg = "Default";
42                                    
43                  try {                  try {
   
                           
44                          QueueConnection connection = connectionFactory.createQueueConnection();                                          QueueConnection connection = connectionFactory.createQueueConnection();                
45                                                    
46                                    
# Line 53  public class ReverserServlet extends Htt Line 51  public class ReverserServlet extends Htt
51                                    
52                  message.setText(msg);                            message.setText(msg);          
53                  message.setJMSReplyTo(responseQueue);                            message.setJMSReplyTo(responseQueue);          
54                                                    
                   
55                  producer.send(message);                  producer.send(message);
                 producer.close();  
                 connection.close();  
                 ///new session for receiving  
56                                    
57                                    
                 connection = connectionFactory.createQueueConnection();  
                 session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);  
58                  QueueReceiver consumer = session.createReceiver(responseQueue);                  QueueReceiver consumer = session.createReceiver(responseQueue);
59                    connection.start(); //incomming messages is not received until a start is given
60                                    
61                                    
62                                    TextMessage reply = (TextMessage) consumer.receive(500); //wait max 500 ms for replay
                 Message reply = consumer.receive(1000); //wait max 500 ms for replay  
63                                                                    
64                                    
65                  if (reply != null)                                if (reply != null)              
66                          response.getWriter().print("Reply: " /*+ reply.getText()*/ );                          response.getWriter().print("Reply: " + reply.getText() );
67                  else                  else
68                          response.getWriter().print("No reply !!!");                          response.getWriter().print("No reply !!!");
69                                    

Legend:
Removed from v.1275  
changed lines
  Added in v.1276

  ViewVC Help
Powered by ViewVC 1.1.20