Instructions
- 1
Open your Java programming software and the project for the queue code. Double-click the code file to open it in the editor.
2Create the URL or file location for the queue. In this example, the queue is set up in the C:queue folder:
String queue = "c:queue";
ConnectionFactory connect = new ActiveMQConnectionFactory(queue);
Connection msg = connect.createConnection();
msg.start();
3 Start the destination session. After you create the folder location, you must start the destination session to listen for new messages. The following code sets up the session listener:
Destination dest = session.createQueue();
4Send a message to the queue to test the new session and messaging service. In this example, a text message is sent to the queue:
MessageProducer pro = session.createProducer(destination);
TextMessage text = session.createTextMessage("my message");
pro.send(text);
No comments:
Post a Comment