Friday 15 March 2013

ejb - Sending message from Message Driven Bean to Session Bean -


I have a program where a session is created in a ejb project and sending a message to a message The queue uses a bean message that operates on a separate project, I manage to retrieve the message sent from Session Bean. Then the message will be used to get other values, which I have to send back to the session bean. Any ideas on how to do it I would appreciate any help.

Operator: (partial code)

  Q connection connection = QEnationFactor.Cracket connection (); Session = queueConnection.create session (wrong, session.AUTO_ACKNOWLEDGE); ReplyQueue = session.createTemporaryQueue (); Consumer = session.createConsumer (replyQueue); Consumer.setMessageListener (new LpsListener); QueueConnection.start (); Creator = session.createProducer (queue); Message = session.createMapMessage (); Message.setJMSReplyTo (replyQueue); Producer.send (message);   

and my MDB: (partial in onmessage)

  msg = message (message message); String memId = msg.getString ("member ID"); Int OK = mmr.getFine (memId); QueueConnection = queueConnectionFactory.createConnection (); ReplyDest = msg.getJMSReplyTo (); ReplyCorrelationMsgId = msg.getJMSMessageID (); Queue session = queue connection.Sant session (true, 0); QueueProducer = queueSession.createProducer (replyDest); AnswerMsg = createReplyMsg (Quation Session, Response MsgId); QueueProducer.send (replyMsg); Responding to creating a private object message (session session, string msgId) throws JMSException {object message message = session .createObjectMessage (); ReplyMsg.setIntProperty ("OK", OK); ReplyMsg.setJMSCorrelationID (msgId); The answer to the return; }    

If you want to send the message back to the new instance of the bean i.e. A stateless bean, you can just inject a new instance of Bean using the @EJB annotation. If you want to send it to a particular Statebank bean, you should have a way of identifying it in the first message like Bean ID. This ID will then be used to identify the bean, when you are sending a return message.

No comments:

Post a Comment