activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: getJMSMessageID on sending message
Date Tue, 11 Jul 2006 14:53:31 GMT
Your code is creating 2 message instances.  It sends the 2nd one, and the
prints out the value from the first.

On 7/11/06, Eugene Prokopiev <prokopiev@stc.donpac.ru> wrote:
>
> Hi,
>
> Can I get MessageID after message sending? With this code:
>
> import javax.jms.Destination;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
> import org.apache.activemq.ActiveMQConnection;
>
> public class Producer {
>
>         public static void main(String[] args) throws Exception {
>
>                 ActiveMQConnection connection =
> ActiveMQConnection.makeConnection("producer1", "pw1",
> "tcp://ccsk-mobile:61616");
>                 connection.start();
>                 Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>                 Destination destination = session.createQueue("
> monitoring.m1");
>                 MessageProducer producer = session.createProducer
> (destination);
>
>                 String text = "Test Message String";
>                 TextMessage message = session.createTextMessage(text);
>                 producer.send(session.createTextMessage());
>                 System.out.println("sent message :
> "+message.getJMSMessageID());
>
>                 session.close();
>                 connection.close();
>         }
>
> }
>
> I got:
>
> sent message : null
>
> --
> Thanks,
> Eugene Prokopiev
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message