问题描述
大家好,我参照http://qjyong.javaeye.com/blog/215171这个文章,一步步的把代码粘贴到工作空间,之后,在publicUserreceiveMessage(){//参数为Destination的JNDI名字去掉前面的模式类型标识MapMessagemsg=(MapMessage)jmsTemplate.receive("registerUserTopic");Useruser=newUser();try{user.setId(msg.getInt("id"));user.setUsername(msg.getString("username"));user.setPassword(msg.getString("password"));user.setEmail(msg.getString("email"));}catch(JMSExceptione){e.printStackTrace();}returnuser;}
中,提示msg.getInt("id")空指针,在消息发送的时候,没有发生异常,publicvoidsendMessage(finalUseruser){//调用模板的send来发送消息jmsTemplate.send(newMessageCreator(){publicMessagecreateMessage(Sessionsession)throwsJMSException{//构造一个要发送的消息MapMessagemessage=session.createMapMessage();message.setInt("id",user.getId());message.setString("username",user.getUsername());message.setString("password",user.getPassword());message.setString("email",user.getEmail());System.out.println("sendsuccess!!");returnmessage;}});
。请各位帮帮忙,大概问题出在哪了。。