Problem while publishing message to the Queue
tpawankumar Sep 5, 2008 6:02 AMHi All,
I am publishing the message to the Queue but second time when i publish the same message it is giving me the following exception
15:23:22,184 ERROR [ClosedInterceptor] ClosedInterceptor.ClientSessionDelegate[7 ]: method createObjectMessage() did not go through, the interceptor is CLOSED 15:23:22,184 ERROR [STDERR] javax.jms.IllegalStateException: The object is close d 15:23:22,184 ERROR [STDERR] at org.jboss.jms.client.container.ClosedIntercep tor.invoke(ClosedInterceptor.java:157) 15:23:22,184 ERROR [STDERR] at org.jboss.aop.advice.PerInstanceInterceptor.i nvoke(PerInstanceInterceptor.java:105) 15:23:22,184 ERROR [STDERR] at org.jboss.jms.client.delegate.ClientSessionDe legate$createObjectMessage_5541516037526997237.invokeNext(ClientSessionDelegate$ createObjectMessage_5541516037526997237.java) 15:23:22,184 ERROR [STDERR] at org.jboss.jms.client.delegate.ClientSessionDe legate.createObjectMessage(ClientSessionDelegate.java) 15:23:22,184 ERROR [STDERR] at org.jboss.jms.client.JBossSession.createObjec tMessage(JBossSession.java:134) 15:23:22,184 ERROR [STDERR] at com.covad.emailmgrservice.helper.VitriaUtil.e mailTriggered(VitriaUtil.java:259) 15:23:22,184 ERROR [STDERR] at com.covad.emailmgrservice.ejb.bean.EmailMgrBe an.sendEmail(EmailMgrBean.java:222) 15:23:22,184 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method) 15:23:22,184 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(N ativeMethodAccessorImpl.java:39) 15:23:22,184 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invo ke(DelegatingMethodAccessorImpl.java:25) 15:23:22,184 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:5 85)
Following is my sender class
public class JmsUtil {
private static InitialContext context=null;
private static QueueSession session=null;
private static QueueConnection conn=null;
static {
initVitria();
}
private static void initVitria() {
try {
Properties prop=new Properties();
prop.setProperty(Constants.INITIAL_FACTORY, Constants.INITIAL_FACTORY_VALUE);
prop.setProperty(Constants.URL_PACKAGE, Constants.URL_PACKAGE_VALUE);
prop.setProperty(Constants.URL_PROVIDER,Constants.URL_PROVIDER_VALUE);
context =new InitialContext(prop);
QueueConnectionFactory connectionFactory=(QueueConnectionFactory)context.lookup("ConnectionFactory");
conn=connectionFactory.createQueueConnection();
session=conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void emailTriggered(String emailType, Map emailAttributes)
throws Exception {
Vector list = new Vector();
Iterator keys = emailAttributes.keySet().iterator();
StringBuffer debugStringBuffer = new StringBuffer();
while (keys.hasNext()) {
String key = (String) keys.next();
Object val = emailAttributes.get(key);
NameValue nv;
if (val == null) {
nv = new NameValue(key, "");
} else {
nv = new NameValue(key, val.toString());
}
list.addElement(nv);
}
NameValue[] nvl = new NameValue[list.size()+2];
for (int i = 0; i < list.size(); i++) {
nvl = (NameValue) list.elementAt(i);
}
NameValue nv=new NameValue("emailType",emailType);
nvl[list.size()]=nv;
nv=new NameValue("orderId","-1");
nvl[list.size()+1]=nv;
System.out.println("inside VitriaUtil 1");
ObjectMessage message =session.createObjectMessage(nvl);
Queue queue=(Queue)context.lookup(Constants.QUEUE_NAME);
QueueSender publisher=session.createSender(queue);
publisher.send(message);
publisher.close();
closeConnection();
System.out.println("message sent");
}
public static void closeConnection(){
try{
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
}Is there something wrong in the code? or is it related something with size of Queue?
I am using the default values for the creation of the Queue.
And i am using Jboss-4.2.1G.A,jboss-messaging-1.3.0.GA and jboss-remoting-2_2_2_SP4.
Please let me know.