This commit is contained in:
Clebert Suconic 2018-04-17 15:10:15 -04:00
commit ec9882c553
3 changed files with 36 additions and 32 deletions

View File

@ -7,7 +7,11 @@ before_install: rm -rf $HOME/.m2/repository/org/apache/activemq/artemis-*
# use 'install' so smoke-tests will work # use 'install' so smoke-tests will work
# use '-Pextra-tests' to ensure extra-tests compiles even though they won't actually run # use '-Pextra-tests' to ensure extra-tests compiles even though they won't actually run
script: mvn -Pfast-tests -Pextra-tests -B install script:
- set -e
- mvn -Pfast-tests -Pextra-tests -B install -q
- cd examples
- mvn install -Prelease install -B -q
cache: cache:
directories: directories:

View File

@ -157,6 +157,7 @@ cd $ARTEMIS_HOME/examples/protocols/openwire/
cd queue; mvn verify; cd .. cd queue; mvn verify; cd ..
cd message-listener; mvn verify; cd .. cd message-listener; mvn verify; cd ..
cd message-recovery; mvn verify; cd .. cd message-recovery; mvn verify; cd ..
cd virtual-topic-mapping; mvn verify; cd ..
cd $ARTEMIS_HOME/examples/protocols/stomp/ cd $ARTEMIS_HOME/examples/protocols/stomp/

View File

@ -35,42 +35,41 @@ import org.apache.activemq.ActiveMQConnectionFactory;
*/ */
public class VirtualTopicMappingExample { public class VirtualTopicMappingExample {
public static void main(final String[] args) throws Exception { public static void main(final String[] args) throws Exception {
Connection connection = null; Connection connection = null;
try { try {
ConnectionFactory cf = new ActiveMQConnectionFactory(); ConnectionFactory cf = new ActiveMQConnectionFactory();
connection = cf.createConnection(); connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//create consumer on queue that is used by the Virtual Topic //create consumer on queue that is used by the Virtual Topic
Queue queue = session.createQueue("Consumer.A.VirtualTopic.Orders"); Queue queue = session.createQueue("Consumer.A.VirtualTopic.Orders");
MessageConsumer messageConsumer = session.createConsumer(queue); MessageConsumer messageConsumer = session.createConsumer(queue);
connection.start(); 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 System.out.println("Sent message with ID: " + message.getJMSMessageID() + " to Topic: " + topic.getTopicName());
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()); //consume the message from the backing queue
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
//consume the message from the backing queue if (messageReceived != null) {
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message with ID: " + messageReceived.getJMSMessageID() + " from Queue: " + queue.getQueueName());
} else {
if (messageReceived != null) { //unexpected outcome
System.out.println("Received message with ID: " + messageReceived.getJMSMessageID() + " from Queue: " + queue.getQueueName()); throw new RuntimeException("EXAMPLE FAILED - No message received from Queue: " + queue.getQueueName());
} else { }
//unexpected outcome } finally {
throw new RuntimeException("EXAMPLE FAILED - No message received from Queue: " + queue.getQueueName()); if (connection != null) {
} connection.close();
} finally { }
if (connection != null) { }
connection.close(); }
}
}
}
} }