To add custom jms properties in jms header you need to add string property to the Text message.
Context ctx = new InitialContext(env);
//ctx.lookup("CreateVASErrorQ20");
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory1"); //Connection Factory JNDI
QueueConnection con = factory.createQueueConnection();
QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctx.lookup("Queue1"); //Find the Queue
QueueSender sender = session.createSender(queue); //Instantiating the message sender
TextMessage message = session.createTextMessage("Message sent again");
message.setStringProperty("system", "prod");
con.start();
sender.send(message);
This will appear in the message like
No comments:
Post a Comment