You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/04/17 19:11:03 UTC
[2/4] activemq-artemis git commit: NO-JIRA fixing checkstyle on
virtual topic mapping example
NO-JIRA fixing checkstyle on virtual topic mapping example
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/186bc446
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/186bc446
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/186bc446
Branch: refs/heads/master
Commit: 186bc4464caa86d89600a16006766c9b2b4c502b
Parents: 1f4e7be
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Apr 17 13:55:04 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Apr 17 15:10:15 2018 -0400
----------------------------------------------------------------------
.../jms/example/VirtualTopicMappingExample.java | 61 ++++++++++----------
1 file changed, 30 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/186bc446/examples/protocols/openwire/virtual-topic-mapping/src/main/java/org/apache/activemq/artemis/jms/example/VirtualTopicMappingExample.java
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/virtual-topic-mapping/src/main/java/org/apache/activemq/artemis/jms/example/VirtualTopicMappingExample.java b/examples/protocols/openwire/virtual-topic-mapping/src/main/java/org/apache/activemq/artemis/jms/example/VirtualTopicMappingExample.java
index 0d0e271..eff7b18 100644
--- a/examples/protocols/openwire/virtual-topic-mapping/src/main/java/org/apache/activemq/artemis/jms/example/VirtualTopicMappingExample.java
+++ b/examples/protocols/openwire/virtual-topic-mapping/src/main/java/org/apache/activemq/artemis/jms/example/VirtualTopicMappingExample.java
@@ -35,42 +35,41 @@ import org.apache.activemq.ActiveMQConnectionFactory;
*/
public class VirtualTopicMappingExample {
- public static void main(final String[] args) throws Exception {
- Connection connection = null;
- try {
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ try {
- ConnectionFactory cf = new ActiveMQConnectionFactory();
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
- connection = cf.createConnection();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- //create consumer on queue that is used by the Virtual Topic
- Queue queue = session.createQueue("Consumer.A.VirtualTopic.Orders");
- MessageConsumer messageConsumer = session.createConsumer(queue);
- connection.start();
+ //create consumer on queue that is used by the Virtual Topic
+ Queue queue = session.createQueue("Consumer.A.VirtualTopic.Orders");
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ connection.start();
+ //send message to virtual topic
+ Topic topic = session.createTopic("VirtualTopic.Orders");
+ MessageProducer producer = session.createProducer(topic);
+ TextMessage message = session.createTextMessage("This is a text message");
+ producer.send(message);
- //send message to virtual topic
- Topic topic = session.createTopic("VirtualTopic.Orders");
- MessageProducer producer = session.createProducer(topic);
- TextMessage message = session.createTextMessage("This is a text message");
- producer.send(message);
+ System.out.println("Sent message with ID: " + message.getJMSMessageID() + " to Topic: " + topic.getTopicName());
- System.out.println("Sent message with ID: " + message.getJMSMessageID() + " to Topic: " + topic.getTopicName());
+ //consume the message from the backing queue
+ TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
- //consume the message from the backing queue
- TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
-
- if (messageReceived != null) {
- System.out.println("Received message with ID: " + messageReceived.getJMSMessageID() + " from Queue: " + queue.getQueueName());
- } else {
- //unexpected outcome
- throw new RuntimeException("EXAMPLE FAILED - No message received from Queue: " + queue.getQueueName());
- }
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
+ if (messageReceived != null) {
+ System.out.println("Received message with ID: " + messageReceived.getJMSMessageID() + " from Queue: " + queue.getQueueName());
+ } else {
+ //unexpected outcome
+ throw new RuntimeException("EXAMPLE FAILED - No message received from Queue: " + queue.getQueueName());
+ }
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
}