Skip to Content

JMS - cannot send email by using ObjectMessage

I have a object message and want to send it in JMS server

here is code:

<code>context =newInitialContext();

queueConnectionFactory=(QueueConnectionFactory)context.lookup(IBusinessConstants.JMS_QUEUE_CONNECTION_FACTORY_JNDI_NAME);

queueConnection = queueConnectionFactory.createQueueConnection();

queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);Queue queue =(Queue)context.lookup(IBusinessConstants.JMS_QUEUE_JNDI_NAME);

log1.errorT("JMS Queue Obtained With Name: "+ queue.getQueueName());

queueSender = queueSession.createSender(queue);ObjectMessage objMsg = queueSession.createObjectMessage();

objMsg.setObject(myBean);

queueConnection.start();

queueSender.send(objMsg);           

log1.errorT("objMsg==>"+objMsg);
log1.errorT("objMsg.getObject()==>"+objMsg.getObject());

In logs view, objMsg is null but objMsg.getObject() has data. It's a root cause why cannot send email ? please suggest me possible solutions.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 05, 2017 at 09:50 AM

    Hello. Cuong According to your description. I am a little about your question. As You said objMsg is null How can you get Object from objMsg?

    and the Scenario you have was you want to send an email. Does that mean "myBean" is email message? Could you provide us more detail about your issue so that we can help to do more analysis? thanks.

    Add comment
    10|10000 characters needed characters exceeded