@Override public TemporaryTopic createTemporaryTopic() throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a temporary topic on a QueueSession"); } try { final ActiveMQTemporaryTopic topic; if (enable1xPrefixes) { topic = ActiveMQDestination.createTemporaryTopic(this, PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString()); } else { topic = ActiveMQDestination.createTemporaryTopic(this); } SimpleString simpleAddress = topic.getSimpleAddress(); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no // subscriptions - core has no notion of a topic session.createTemporaryQueue(simpleAddress, simpleAddress, ActiveMQSession.REJECTING_FILTER); connection.addTemporaryQueue(simpleAddress); return topic; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
@Test public void testTemporaryTopic() throws Exception { Connection connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // javax.jms.Topic topic = ActiveMQJMSClient.createTopic(QUEUE_NAME); ActiveMQTemporaryTopic topic = (ActiveMQTemporaryTopic) session.createTemporaryTopic(); MessageConsumer consumer = session.createConsumer(topic); MessageProducer producer = session.createProducer(topic); producer.send(session.createTextMessage("msg")); connection.start(); assertNotNull(consumer.receive(500)); SimpleString topicAddress = topic.getSimpleAddress(); consumer.close(); assertNotNull(server.locateQueue(topicAddress)); IntegrationTestLogger.LOGGER.info("Topic name: " + topicAddress); topic.delete(); connection.close(); // assertNotNull(server.getManagementService().getResource("jms.topic.test")); assertNull(server.locateQueue(topicAddress)); }
@Override public TemporaryTopic createTemporaryTopic() throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a temporary topic on a QueueSession"); } try { final ActiveMQTemporaryTopic topic; if (enable1xPrefixes) { topic = ActiveMQDestination.createTemporaryTopic(this, PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString()); } else { topic = ActiveMQDestination.createTemporaryTopic(this); } SimpleString simpleAddress = topic.getSimpleAddress(); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no // subscriptions - core has no notion of a topic session.createTemporaryQueue(simpleAddress, simpleAddress, ActiveMQSession.REJECTING_FILTER); connection.addTemporaryQueue(simpleAddress); return topic; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
@Override public TemporaryTopic createTemporaryTopic() throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a temporary topic on a QueueSession"); } try { final ActiveMQTemporaryTopic topic; if (enable1xPrefixes) { topic = ActiveMQDestination.createTemporaryTopic(this, PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString()); } else { topic = ActiveMQDestination.createTemporaryTopic(this); } SimpleString simpleAddress = topic.getSimpleAddress(); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no // subscriptions - core has no notion of a topic session.createTemporaryQueue(simpleAddress, simpleAddress, ActiveMQSession.REJECTING_FILTER); connection.addTemporaryQueue(simpleAddress); return topic; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
@Override public TemporaryTopic createTemporaryTopic() throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a temporary topic on a QueueSession"); } try { final ActiveMQTemporaryTopic topic; if (enable1xPrefixes) { topic = ActiveMQDestination.createTemporaryTopic(this, PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString()); } else { topic = ActiveMQDestination.createTemporaryTopic(this); } SimpleString simpleAddress = topic.getSimpleAddress(); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no // subscriptions - core has no notion of a topic session.createTemporaryQueue(simpleAddress, simpleAddress, ActiveMQSession.REJECTING_FILTER); connection.addTemporaryQueue(simpleAddress); return topic; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
@Override public TemporaryTopic createTemporaryTopic() throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a temporary topic on a QueueSession"); } try { final ActiveMQTemporaryTopic topic; if (enable1xPrefixes) { topic = ActiveMQDestination.createTemporaryTopic(this, PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString()); } else { topic = ActiveMQDestination.createTemporaryTopic(this); } SimpleString simpleAddress = topic.getSimpleAddress(); // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS // checks when routing messages to a topic that // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no // subscriptions - core has no notion of a topic session.createTemporaryQueue(simpleAddress, simpleAddress, ActiveMQSession.REJECTING_FILTER); connection.addTemporaryQueue(simpleAddress); return topic; } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }