title: Sending message from Message Driven Bean to Session Bean
body: <p>I have a program where a session bean is created in one ejb project and uses a queue to send a message over to a message driven bean at a separate project. At the message driven bean, I manage to retrieve the message sent over from the session bean. The message will then be used to get another value, which I have to send back to the session bean. Any ideas on how to do it. Many thanks for any help given. </p>
  
  <p>ManagerBean:(partial code)</p>
  
  <pre><code>            queueConnection=queueConnectionFactory.createConnection();
              session=queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              replyQueue=session.createTemporaryQueue();
              consumer=session.createConsumer(replyQueue);
              consumer.setMessageListener(new LpsListener());
              queueConnection.start();
              producer=session.createProducer(queue);
  
              message=session.createMapMessage();
              message.setJMSReplyTo(replyQueue);
              producer.send(message);
  </code></pre>
  
  <p>and my MDB:(partial in OnMessage)</p>
  
  <pre><code>            msg=(MapMessage)message;
  
              String memId=msg.getString("MemberId");
              int fine=mmr.getFine(memId);
  
              queueConnection=queueConnectionFactory.createConnection();
              replyDest=msg.getJMSReplyTo();
              replyCorrelationMsgId=msg.getJMSMessageID();
              queueSession=queueConnection.createSession(true, 0);
              queueProducer=queueSession.createProducer(replyDest);
              replyMsg=createReplyMsg(queueSession, replyCorrelationMsgId);
              queueProducer.send(replyMsg);
  
              private ObjectMessage createReplyMsg(Session session, String msgId)throws                      JMSException{
              ObjectMessage replyMsg=session.createObjectMessage();
              replyMsg.setIntProperty("fine", fine);
              replyMsg.setJMSCorrelationID(msgId);
              return replyMsg;
              }
  </code></pre>