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.
ManagerBean:(partial 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);
and my MDB:(partial in OnMessage)
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;
}
createReplyMsg
. – Nayan WadekarManagerBean
to listen to the specific queue to which MDB replies. It's difficult to pinpoint issue, try to debug yourself, whether message sending fails, is it received properly at other end etc. – Nayan Wadekar