I've tried to extract the relevant code snippets from our application. 

If the method sendPriceMessage() is called repeatedly with differing arguments, 
say

sendPriceMessage(priceA);
sendPriceMessage(priceB);
sendPriceMessage(priceC);

the consumer receives priceA three times.

Hope this clarifies the issue. 

Thanks. 


  | package notification;
  | 
  | import javax.jms.*;
  | import javax.naming.*;
  | 
  | public class PriceChangePublisher {
  | 
  |   private TopicConnection topicConnection;
  |   private TopicSession topicSession;
  |   private TopicPublisher topicSender;
  |   private ObjectMessage priceMsg = null;
  | 
  |   public PriceChangePublisher() {
  |     try {
  |       InitialContext ic = ServerConnectionHelper.getInitialContext();
  |       Topic topic = ServerConnectionHelper.getPriceNotificationTopic(ic);
  |       TopicConnectionFactory factory = 
ServerConnectionHelper.getTopicConnectionFactory(ic);
  |       topicConnection = factory.createTopicConnection();
  |       topicConnection.setClientID("PricePublisher");
  |       topicSession = topicConnection.createTopicSession(false, 
TopicSession.AUTO_ACKNOWLEDGE);
  |       topicSender = topicSession.createPublisher(topic);
  |       topicConnection.start();
  |       topicSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
  |       topicSender.setTimeToLive(300000);
  |     } catch (Exception e) {
  |       e.printStackTrace();
  |     }
  |   }
  | 
  |   public void sendPriceMessage(PriceModel price) {
  |     long timestamp = price.getTimeStamp().getTime();
  |     try {
  |       if (priceMsg == null) {
  |         priceMsg = topicSession.createObjectMessage();
  |       }
  |       synchronized (priceMsg) {
  |         // priceMsg.clearBody(); 
  |         priceMsg.setObject(price);
  |         priceMsg.setLongProperty("TIMESTAMP", timestamp);
  |         topicSender.publish(priceMsg);
  |       }
  |     } catch (Exception e) {
  |       e.printStackTrace();
  |     }
  |   }
  | 
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955793#3955793

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955793

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to