JavaQuick Tip: Java Message Service Class

Quick Tip: Java Message Service Class

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Java Developer Tutorials

This Java programming tutorial teaches developers how to create a Java Message Service (JMS) class. Here is some Java example code showcasing how this is done:

*/

public class JmsAppSpecificProps
{
	public static void main(String args[])
	{
		...
	}
	
	protected void writeMessage(String text) throws JMSException
	{
		TextMessage textMessage = publishSession.createTextMessage();
		textMessage.setText(text); //Message
		textMessage.setStringProperty("serverURL","https://10.77.62.12/hint"); //application specific property
		publisher.publish(textMessage); //publishing the message
	}
}

/*

Running this code will result in the following output:

The property serverURL will be published along with the standard message

Read more Java programming and development tutorials.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories