Calling MDB from JBOSSESB Service
govindaattal Jul 17, 2007 9:45 AMHello,
I have some MDBs developed using 2.1 Spec running on
JBOSS 4.0.5 AS along with JBOSSESB 4.2MR2.
I wish to call them in JBOSSESB services.
Please correct me if I am wrong...
I thought that it can be acheived in two ways,
1. calling MDB using initialContext/connection/session/queue inside an Action in the pipeline
2. Using JMSrouter and passing jndiName of queue of the MDB as property....
For first method:-
Body msgBody = actualInutMessage.getBody(); String strContents = new String(msgBody.getContents()); InitialContext initCtx = new InitialContext(); Object tmp = initCtx.lookup("QueueConnectionFactory"); QueueConnectionFactory qConFactory = (QueueConnectionFactory)tmp; mdbQueue = (Queue)initCtx.lookup("queue/TrialTextService"); conn = qConFactory.createQueueConnection(); session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); conn.start(); QueueSender sender = session.createSender(mdbQueue); TextMessage txtMessage = session.createTextMessage(); txtMessage.setText(strContents); sender.send(txtMessage); conn.stop(); session.close(); conn.close(); return actualInutMessage;
But for this method I cannot call conn.stop()/conn.close()/session.close() ... as against J2EE Specs 1.4 Section 6.6 {---- JBOSS AS gave me error messages on the console -----}
At the same time I cannot have innumerable jms connections without closing them. So for the time I have made connections and sessions as static variables.
I am not happy with this solution. One reason I keep connections open for may be life time.....
Now the second soltion using JMSRouter...
<action name="callMDB" class="org.jboss.soa.esb.actions.routing.JMSRouter"> <property name="jndiName" value="queue/TrialTextService"/> <property name="unwrap" value="true"></property> </action>
here jndiname=queue/TrialTextService
is jndi value for queue of the message driven bean. I think unwrapping the message will send [JBOSS ESB Aware message] minus [jboss esb specific headers/properties] ie., [message body only ]to queue of the MDB....
Now I have a problem....
My MDB is configured to receive TextMessage; Client sends a text Message.
But when this action JMSRouter is applied it sends Bytes Message to MDB....
My question is,
What ways an ESB service to send
TextMessage, ObjectMessage, MapMessage, XMLMessage to Actual JMS services (business services.... I prefer to call esb services as proxy services.....) ?