[jboss-user] [JBoss Messaging] - Properties inside an ObjectMessage becomes a HashMap

sll74 do-not-reply at jboss.com
Thu Nov 29 03:43:03 EST 2007


Hi
We are running the following test:
A producer sends an ObjectMessage with a Properties inside to a Queue.
A consumer dequeues the ObjectMessage from the Queue, but we found an HashMap instead of a Properties.


  | Procuder:
  | 
  |        if ( !initError ){
  |            Session session = null;
  |            MessageProducer publisher = null;
  |            ObjectMessage message = null;
  |            int numMsgs = ciclesNumber.intValue();
  | 
  |            try {
  |                StringBuffer sb = new StringBuffer();
  |                properties = new Properties();
  | 
  |                for (int i = 0; i < numMsgs; i++) {
  |                    if ( stop ){
  |                        break;
  |                    }
  |                    session = connection.createSession(false, 0); //autocommit
  |                    publisher = session.createProducer(dest);
  |                    message = session.createObjectMessage();
  |                    properties.clear();
  |                    properties.put("properties iteration",
  | String.valueOf( i ) );
  |                    message.setIntProperty("iteration", i );
  |                    message.setObject( properties );
  | 
  |                    sb.setLength( 0 );
  |                    sb.append( " iteration number : " ).append( i );
  |                    log.info( sb.toString() );
  | 
  |                    publisher.send( message, DeliveryMode.PERSISTENT,
  | Message.DEFAULT_PRIORITY, timeToLive.intValue() );
  | 
  |                    session.close();
  |                }
  |                mess = "messaggio spedito";
  |            } catch (Throwable t) {
  |                // JMSException could be thrown
  |                mess = t.toString();
  |                log.error("PublisherBean.publishNews: ", t);
  |            }
  |        }
  | 


  | Consumer:
  | 
  |      ObjectMessage msg = null;
  |      StringBuffer sb = new StringBuffer();
  | 
  |      try {
  |        if (message instanceof ObjectMessage ) {
  |          msg = (ObjectMessage) message;
  |          Integer id = msg.getIntProperty("iteration");
  |          sb.setLength( 0 );
  |          sb.append( "MESSAGE BEAN: IntProperty iteration: " ).append( id );
  |          log.info( sb );
  |          Object array = msg.getObject();
  |          log.info( array.getClass() );
  | 
  |          long now = System.currentTimeMillis();
  | 
  |          while(true){
  |              if ( System.currentTimeMillis() - now > 10000 )
  |                  break;
  |          }
  | 
  |        } else {
  |          log.warn("Message of wrong type: " + message.getClass().getName());
  |        }
  |      } catch (JMSException e) {
  |        e.printStackTrace();
  |      } catch (Throwable te) {
  |        te.printStackTrace();
  |      }
  | 

The cosumer writes:


  | base.MessageMdb.onMessage INFO - class java.util.HashMap
  | 

Any hints?

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

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



More information about the jboss-user mailing list