public static Destination fromPrefixedName(final String name) { return fromPrefixedName(name, name); }
@Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { SimpleString address = MessageUtil.getJMSReplyTo(message); if (address != null) { if (enable1xPrefixes) { replyTo = ActiveMQDestination.fromPrefixedName(get1xPrefixedName(address.toString())); } else { replyTo = ActiveMQDestination.fromPrefixedName(address.toString()); } } } return replyTo; }
@Override public Destination getJMSDestination() throws JMSException { if (dest == null) { SimpleString address = message.getAddressSimpleString(); SimpleString name = address; if (address != null & enable1xPrefixes) { dest = ActiveMQDestination.fromPrefixedName(get1xPrefixedName(address.toString())); } else { if (address == null) { dest = null; } else if (RoutingType.ANYCAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createQueue(address); } else if (RoutingType.MULTICAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createTopic(address); } else { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } if (name != null) { ((ActiveMQDestination) dest).setName(name.toString()); } } } return dest; }
public static Destination fromPrefixedName(final String name) { return fromPrefixedName(name, name); }
public static Destination fromPrefixedName(final String name) { return fromPrefixedName(name, name); }
public static Destination fromPrefixedName(final String name) { return fromPrefixedName(name, name); }
public static Destination fromPrefixedName(final String name) { return fromPrefixedName(name, name); }
@Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { SimpleString repl = MessageUtil.getJMSReplyTo(message); if (repl != null) { replyTo = ActiveMQDestination.fromPrefixedName(repl.toString()); } } return replyTo; }
@Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { SimpleString repl = MessageUtil.getJMSReplyTo(message); if (repl != null) { replyTo = ActiveMQDestination.fromPrefixedName(repl.toString()); } } return replyTo; }
@Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { SimpleString address = MessageUtil.getJMSReplyTo(message); if (address != null) { if (enable1xPrefixes) { replyTo = ActiveMQDestination.fromPrefixedName(get1xPrefixedName(address.toString())); } else { replyTo = ActiveMQDestination.fromPrefixedName(address.toString()); } } } return replyTo; }
@Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { SimpleString address = MessageUtil.getJMSReplyTo(message); if (address != null) { if (enable1xPrefixes) { replyTo = ActiveMQDestination.fromPrefixedName(get1xPrefixedName(address.toString())); } else { replyTo = ActiveMQDestination.fromPrefixedName(address.toString()); } } } return replyTo; }
private void jmsSendMessage(Serializable value, String destName, boolean isQueue) throws JMSException { ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616"); String jmsDest; if (isQueue) { jmsDest = QUEUE_QUALIFIED_PREFIX + destName; } else { jmsDest = TOPIC_QUALIFIED_PREFIX + destName; } Destination destination = ActiveMQDestination.fromPrefixedName(jmsDest); Connection conn = factory.createConnection(); try { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(destination); ObjectMessage message = session.createObjectMessage(); message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml"); message.setObject(value); producer.send(message); } finally { conn.close(); } } }
@Test public void testFromAddressWithInvalidPrefix() throws Exception { String invalidPrefix = "junk"; String destinationName = RandomUtil.randomString(); String address = invalidPrefix + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Destination); }
@Test public void testEquals() throws Exception { String destinationName = RandomUtil.randomString(); String address = QUEUE_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); ActiveMQDestination sameDestination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); ActiveMQDestination differentDestination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address + RandomUtil.randomString()); Assert.assertFalse(destination.equals(null)); Assert.assertTrue(destination.equals(destination)); Assert.assertTrue(destination.equals(sameDestination)); Assert.assertFalse(destination.equals(differentDestination)); }
@Test public void testFromAddressWithTopicAddressPrefix() throws Exception { String destinationName = RandomUtil.randomString(); String address = TOPIC_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Topic); Assert.assertEquals(destinationName, ((Topic) destination).getTopicName()); }
@Test public void testFromAddressWithQueueAddressPrefix() throws Exception { String destinationName = RandomUtil.randomString(); String address = QUEUE_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Queue); Assert.assertEquals(destinationName, ((Queue) destination).getQueueName()); }
@Override public Destination getJMSDestination() throws JMSException { if (dest == null) { SimpleString address = message.getAddressSimpleString(); SimpleString changedAddress = checkPrefix(address); if (address == null) { dest = null; } else if (RoutingType.ANYCAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createQueue(address); } else if (RoutingType.MULTICAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createTopic(address); } else { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } if (changedAddress != null && dest != null) { ((ActiveMQDestination) dest).setName(changedAddress.toString()); } } return dest; }
@Override public Destination getJMSDestination() throws JMSException { if (dest == null) { SimpleString address = message.getAddressSimpleString(); SimpleString changedAddress = checkPrefix(address); if (address == null) { dest = null; } else if (RoutingType.ANYCAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createQueue(address); } else if (RoutingType.MULTICAST.equals(message.getRoutingType())) { dest = ActiveMQDestination.createTopic(address); } else { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } if (changedAddress != null && dest != null) { ((ActiveMQDestination) dest).setName(changedAddress.toString()); } } return dest; }
static Destination findCompatibleReplyTo(ClientMessage message) { SimpleString address = MessageUtil.getJMSReplyTo(message); if (address != null) { final SimpleString checkedAddress = checkPrefix1X(address); if (checkedAddress != null) { return ActiveMQDestination.fromPrefixed1XName(address.toString(), checkedAddress.toString()); } String name = address.toString(); // swap the old prefixes for the new ones so the proper destination type gets created if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); } return ActiveMQDestination.fromPrefixedName(address.toString(), name); } return null; }
static Destination findCompatibleReplyTo(ClientMessage message) { SimpleString address = MessageUtil.getJMSReplyTo(message); if (address != null) { final SimpleString checkedAddress = checkPrefix1X(address); if (checkedAddress != null) { return ActiveMQDestination.fromPrefixed1XName(address.toString(), checkedAddress.toString()); } String name = address.toString(); // swap the old prefixes for the new ones so the proper destination type gets created if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); } return ActiveMQDestination.fromPrefixedName(address.toString(), name); } return null; }