@Override public String toString() { return "ActiveMQTemporaryTopic[" + getAddress() + "]"; }
public static ActiveMQTemporaryTopic createTemporaryTopic(String address, final ActiveMQSession session) { return new ActiveMQTemporaryTopic(address, session); }
@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 boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ActiveMQTemporaryTopic)) { return false; } ActiveMQTemporaryTopic that = (ActiveMQTemporaryTopic) o; return super.getAddress().equals(that.getAddress()); }
} else if (addr.startsWith(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX)) { address = addr.substring(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX.length()); destination = new ActiveMQTemporaryTopic(address, null); } else { destination = new ActiveMQDestination(addr, TYPE.DESTINATION, null);
@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 String toString() { return "ActiveMQTemporaryTopic[" + getAddress() + "]"; }
public static ActiveMQTemporaryTopic createTemporaryTopic(String address, final ActiveMQSession session) { return new ActiveMQTemporaryTopic(address, session); }
@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 String toString() { return "ActiveMQTemporaryTopic[" + getAddress() + "]"; }
public static ActiveMQTemporaryTopic createTemporaryTopic(String address, final ActiveMQSession session) { return new ActiveMQTemporaryTopic(address, session); }
@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 boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ActiveMQTemporaryTopic)) { return false; } ActiveMQTemporaryTopic that = (ActiveMQTemporaryTopic) o; return super.getAddress().equals(that.getAddress()); }
public static ActiveMQTemporaryTopic createTemporaryTopic(String address, final ActiveMQSession session) { return new ActiveMQTemporaryTopic(address, session); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ActiveMQTemporaryTopic)) { return false; } ActiveMQTemporaryTopic that = (ActiveMQTemporaryTopic) o; return super.getAddress().equals(that.getAddress()); }
public static ActiveMQTemporaryTopic createTemporaryTopic(String address, final ActiveMQSession session) { return new ActiveMQTemporaryTopic(address, session); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof ActiveMQTemporaryTopic)) { return false; } ActiveMQTemporaryTopic that = (ActiveMQTemporaryTopic) o; return super.getAddress().equals(that.getAddress()); }
public static Destination fromPrefixedName(final String addr, final String name) { ActiveMQDestination destination; if (addr.startsWith(ActiveMQDestination.QUEUE_QUALIFIED_PREFIX)) { String address = addr.substring(ActiveMQDestination.QUEUE_QUALIFIED_PREFIX.length()); destination = createQueue(address); } else if (addr.startsWith(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX)) { String address = addr.substring(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX.length()); destination = createTopic(address); } else if (addr.startsWith(ActiveMQDestination.TEMP_QUEUE_QUALIFED_PREFIX)) { String address = addr.substring(ActiveMQDestination.TEMP_QUEUE_QUALIFED_PREFIX.length()); destination = new ActiveMQTemporaryQueue(address, null); } else if (addr.startsWith(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX)) { String address = addr.substring(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX.length()); destination = new ActiveMQTemporaryTopic(address, null); } else { destination = new ActiveMQDestination(addr, TYPE.DESTINATION, null); } String unprefixedName = name; if (name.startsWith(ActiveMQDestination.QUEUE_QUALIFIED_PREFIX)) { unprefixedName = name.substring(ActiveMQDestination.QUEUE_QUALIFIED_PREFIX.length()); } else if (name.startsWith(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX)) { unprefixedName = name.substring(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX.length()); } else if (name.startsWith(ActiveMQDestination.TEMP_QUEUE_QUALIFED_PREFIX)) { unprefixedName = name.substring(ActiveMQDestination.TEMP_QUEUE_QUALIFED_PREFIX.length()); } else if (name.startsWith(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX)) { unprefixedName = name.substring(ActiveMQDestination.TEMP_TOPIC_QUALIFED_PREFIX.length()); } destination.setName(unprefixedName); return destination; }