org.apache.activemq.command.ActiveMQTopic Java Examples
The following examples show how to use
org.apache.activemq.command.ActiveMQTopic.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DestinationListenerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testDestiationSourceHasInitialDestinations() throws Exception { Thread.sleep(1000); DestinationSource destinationSource = connection.getDestinationSource(); Set<ActiveMQQueue> queues = destinationSource.getQueues(); Set<ActiveMQTopic> topics = destinationSource.getTopics(); LOG.info("Queues: " + queues); LOG.info("Topics: " + topics); assertTrue("The queues should not be empty!", !queues.isEmpty()); assertTrue("The topics should not be empty!", !topics.isEmpty()); assertTrue("queues contains initial queue: " + queues, queues.contains(sampleQueue)); assertTrue("topics contains initial topic: " + queues, topics.contains(sampleTopic)); }
Example #2
Source File: OpenWireConnection.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void tempQueueDeleted(SimpleString bindingName) { ActiveMQDestination dest = new ActiveMQTempQueue(bindingName.toString()); state.removeTempDestination(dest); if (!AdvisorySupport.isAdvisoryTopic(dest)) { AMQConnectionContext context = getContext(); DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest); ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest); try { protocolManager.fireAdvisory(context, topic, advInfo); } catch (Exception e) { logger.warn("Failed to fire advisory on " + topic, e); } } }
Example #3
Source File: TopicBridgeStandaloneReconnectTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { localConnectionFactory = createLocalConnectionFactory(); foreignConnectionFactory = createForeignConnectionFactory(); outbound = new ActiveMQTopic("RECONNECT.TEST.OUT.TOPIC"); inbound = new ActiveMQTopic("RECONNECT.TEST.IN.TOPIC"); jmsTopicConnector = new SimpleJmsTopicConnector(); // Wire the bridges. jmsTopicConnector.setOutboundTopicBridges(new OutboundTopicBridge[]{new OutboundTopicBridge("RECONNECT.TEST.OUT.TOPIC")}); jmsTopicConnector.setInboundTopicBridges(new InboundTopicBridge[]{new InboundTopicBridge("RECONNECT.TEST.IN.TOPIC")}); // Tell it how to reach the two brokers. jmsTopicConnector.setOutboundTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61617")); jmsTopicConnector.setLocalTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616")); }
Example #4
Source File: IgniteMqttStreamerTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception If failed. */ @Test public void testMultipleTopics_MultipleQoS_OneEntryPerMessage() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); streamer.setTopics(MULTIPLE_TOPIC_NAMES); streamer.setQualitiesOfService(Arrays.asList(1, 1, 1, 1)); // subscribe to cache PUT events CountDownLatch latch = subscribeToPutEvents(50); // action time streamer.start(); // send messages sendMessages(MULTIPLE_TOPIC_NAMES, 0, 50, false); // assertions assertTrue(latch.await(10, TimeUnit.SECONDS)); assertCacheEntriesLoaded(50); assertTrue(broker.getBroker().getDestinationMap().size() >= 4); assertTrue(broker.getBroker().getDestinationMap().containsKey(new ActiveMQTopic("def"))); assertTrue(broker.getBroker().getDestinationMap().containsKey(new ActiveMQTopic("ghi"))); }
Example #5
Source File: TopicSubscriptionZeroPrefetchTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { brokerService = createBroker(); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost"); activeMQConnectionFactory.setWatchTopicAdvisories(true); connection = activeMQConnectionFactory.createConnection(); connection.setClientID("ClientID-1"); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = new ActiveMQTopic(TOPIC_NAME); producer = session.createProducer(destination); connection.start(); }
Example #6
Source File: SecureDLQTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public static AuthorizationMap createAuthorizationMap() { DestinationMap readAccess = new DefaultAuthorizationMap(); readAccess.put(new ActiveMQQueue("TEST"), ADMINS); readAccess.put(new ActiveMQQueue("TEST"), USERS); readAccess.put(new ActiveMQQueue("ActiveMQ.DLQ"), ADMINS); DestinationMap writeAccess = new DefaultAuthorizationMap(); writeAccess.put(new ActiveMQQueue("TEST"), ADMINS); writeAccess.put(new ActiveMQQueue("TEST"), USERS); writeAccess.put(new ActiveMQQueue("ActiveMQ.DLQ"), ADMINS); readAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD); writeAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD); DestinationMap adminAccess = new DefaultAuthorizationMap(); adminAccess.put(new ActiveMQQueue("TEST"), ADMINS); adminAccess.put(new ActiveMQQueue("TEST"), USERS); adminAccess.put(new ActiveMQQueue("ActiveMQ.DLQ"), ADMINS); adminAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD); return new SimpleAuthorizationMap(writeAccess, readAccess, adminAccess); }
Example #7
Source File: SupervisionJmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public JmsTemplate supervisionTopicPublisherJmsTemplate() { int ttl = properties.getJms().getClientTopicMsgTimeToLive(); JmsTemplate jmsTemplate = JmsTopicTemplateFactory.createJmsTemplate(clientSingleConnectionFactory, ttl); String supervisionTopic = properties.getJms().getSupervisionTopic(); jmsTemplate.setDefaultDestination(new ActiveMQTopic(supervisionTopic)); return jmsTemplate; }
Example #8
Source File: LargeMessageTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Destination createDestination() { String subject = getClass().getName(); if (isTopic) { return new ActiveMQTopic(subject); } else { return new ActiveMQQueue(subject); } }
Example #9
Source File: ActiveJmsSender.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void sendToTopic(final String text, final String jmsTopicName) { if (text == null) { throw new NullPointerException("Attempting to send a null text message."); } Destination topic = new ActiveMQTopic(jmsTopicName); jmsTemplate.send(topic, new MessageCreator() { @Override public Message createMessage(Session session) throws JMSException { return session.createTextMessage(text); } }); }
Example #10
Source File: LDAPAuthorizationMapTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testGetAdminACLs() { ActiveMQDestination q1 = new ActiveMQQueue("queue1"); Set<GroupPrincipal> aclsq1 = authMap.getAdminACLs(q1); assertEquals(1, aclsq1.size()); assertTrue(aclsq1.contains(new GroupPrincipal("role1"))); ActiveMQDestination t1 = new ActiveMQTopic("topic1"); Set<GroupPrincipal> aclst1 = authMap.getAdminACLs(t1); assertEquals(1, aclst1.size()); assertTrue(aclst1.contains(new GroupPrincipal("role1"))); }
Example #11
Source File: DestinationFilterTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testMatchesChild() throws Exception { DestinationFilter filter = DestinationFilter.parseFilter(new ActiveMQQueue("A.*.C")); assertFalse("Filter matched wrong destination type", filter.matches(new ActiveMQTopic("A.B"))); assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B.C"))); filter = DestinationFilter.parseFilter(new ActiveMQQueue("A.*")); assertTrue("Filter did not match", filter.matches(new ActiveMQQueue("A.B"))); assertFalse("Filter did match", filter.matches(new ActiveMQQueue("A"))); }
Example #12
Source File: RemoveDestinationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testRemoveDestinationWithoutSubscriber() throws Exception { ActiveMQConnection amqConnection = (ActiveMQConnection) createConnection(true); DestinationSource destinationSource = amqConnection.getDestinationSource(); Session session = amqConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic("TEST.FOO"); MessageProducer producer = session.createProducer(topic); MessageConsumer consumer = session.createConsumer(topic); TextMessage msg = session.createTextMessage("Hellow World"); producer.send(msg); assertNotNull(consumer.receive(5000)); Thread.sleep(1000); ActiveMQTopic amqTopic = (ActiveMQTopic) topic; assertTrue(destinationSource.getTopics().contains(amqTopic)); consumer.close(); producer.close(); session.close(); Thread.sleep(3000); amqConnection.destroyDestination((ActiveMQDestination) topic); Thread.sleep(3000); assertFalse(destinationSource.getTopics().contains(amqTopic)); }
Example #13
Source File: ManagedDurableSubscriptionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); topic = (ActiveMQTopic) createDestination(); startBroker(); }
Example #14
Source File: TopicSubscriptionSlowConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { brokerService = createBroker(); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost"); activeMQConnectionFactory.setWatchTopicAdvisories(true); connection = activeMQConnectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = new ActiveMQTopic(TOPIC_NAME); producer = session.createProducer(destination); connection.start(); }
Example #15
Source File: PooledTopicPublisherTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testJmsPoolConnectionFactory() throws Exception { ActiveMQTopic topic = new ActiveMQTopic("test"); pcf = createPooledConnectionFactory(); connection = (TopicConnection) pcf.createConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); TopicPublisher publisher = session.createPublisher(topic); publisher.publish(session.createMessage()); }
Example #16
Source File: NoDuplicateOnTopicNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private BrokerService createAndStartBroker(String name, String addr) throws Exception { BrokerService broker = new BrokerService(); broker.setDeleteAllMessagesOnStartup(true); broker.setBrokerName(name); broker.addConnector(addr).setDiscoveryUri(new URI(MULTICAST_DEFAULT)); broker.setUseJmx(false); NetworkConnector networkConnector = broker.addNetworkConnector(MULTICAST_DEFAULT); networkConnector.setDecreaseNetworkConsumerPriority(true); networkConnector.setDynamicOnly(dynamicOnly); networkConnector.setNetworkTTL(ttl); networkConnector.setSuppressDuplicateTopicSubscriptions(suppressDuplicateTopicSubs); networkConnector.setConsumerPriorityBase(BASE_PRIORITY); networkConnector.addStaticallyIncludedDestination(new ActiveMQTopic("BeStaticallyIncluded")); PolicyMap policyMap = new PolicyMap(); PolicyEntry policy = new PolicyEntry(); policy.setDispatchPolicy(dispatchPolicy); // the audit will suppress the duplicates as it defaults to true so this test // checking for dups will fail. it is good to have it on in practice. policy.setEnableAudit(false); policyMap.put(new ActiveMQTopic(TOPIC_NAME), policy); broker.setDestinationPolicy(policyMap); broker.start(); return broker; }
Example #17
Source File: TopicClusterTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Destination createDestination(String name) { if (topic) { return new ActiveMQTopic(name); } else { return new ActiveMQQueue(name); } }
Example #18
Source File: SimpleSecurityBrokerSystemTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public static AuthorizationMap createAuthorizationMap() { DestinationMap readAccess = new DefaultAuthorizationMap(); readAccess.put(new ActiveMQQueue(">"), ADMINS); readAccess.put(new ActiveMQQueue("USERS.>"), USERS); readAccess.put(new ActiveMQQueue("GUEST.>"), GUESTS); readAccess.put(new ActiveMQTopic(">"), ADMINS); readAccess.put(new ActiveMQTopic("USERS.>"), USERS); readAccess.put(new ActiveMQTopic("GUEST.>"), GUESTS); DestinationMap writeAccess = new DefaultAuthorizationMap(); writeAccess.put(new ActiveMQQueue(">"), ADMINS); writeAccess.put(new ActiveMQQueue("USERS.>"), USERS); writeAccess.put(new ActiveMQQueue("GUEST.>"), USERS); writeAccess.put(new ActiveMQQueue("GUEST.>"), GUESTS); writeAccess.put(new ActiveMQTopic(">"), ADMINS); writeAccess.put(new ActiveMQTopic("USERS.>"), USERS); writeAccess.put(new ActiveMQTopic("GUEST.>"), USERS); writeAccess.put(new ActiveMQTopic("GUEST.>"), GUESTS); readAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD); writeAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD); DestinationMap adminAccess = new DefaultAuthorizationMap(); adminAccess.put(new ActiveMQTopic(">"), ADMINS); adminAccess.put(new ActiveMQTopic(">"), USERS); adminAccess.put(new ActiveMQTopic(">"), GUESTS); adminAccess.put(new ActiveMQQueue(">"), ADMINS); adminAccess.put(new ActiveMQQueue(">"), USERS); adminAccess.put(new ActiveMQQueue(">"), GUESTS); return new SimpleAuthorizationMap(writeAccess, readAccess, adminAccess); }
Example #19
Source File: DurableSubscriptionOfflineTestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Destination createDestination(String subject) { if (isTopic) { return new ActiveMQTopic(subject); } else { return new ActiveMQQueue(subject); } }
Example #20
Source File: SimpleAuthenticationPluginSeparatorTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * @see {@link CombinationTestSupport} */ @Override public void initCombosForTestUserReceiveSucceeds() { addCombinationValues("userName", new Object[]{"user"}); addCombinationValues("password", new Object[]{"password"}); addCombinationValues("destination", new Object[]{new ActiveMQQueue("USERS/FOO"), new ActiveMQTopic("USERS/FOO")}); }
Example #21
Source File: XBeanConfigTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testBrokerConfiguredCorrectly() throws Exception { // Validate the system properties are being evaluated in xbean. assertEquals("testbroker", brokerService.getBrokerName()); Topic topic = (Topic) broker.addDestination(context, new ActiveMQTopic("FOO.BAR"), true); DispatchPolicy dispatchPolicy = topic.getDispatchPolicy(); assertTrue("dispatchPolicy should be RoundRobinDispatchPolicy: " + dispatchPolicy, dispatchPolicy instanceof RoundRobinDispatchPolicy); SubscriptionRecoveryPolicy subscriptionRecoveryPolicy = topic.getSubscriptionRecoveryPolicy(); subscriptionRecoveryPolicy = ((RetainedMessageSubscriptionRecoveryPolicy) subscriptionRecoveryPolicy).getWrapped(); assertTrue("subscriptionRecoveryPolicy should be LastImageSubscriptionRecoveryPolicy: " + subscriptionRecoveryPolicy, subscriptionRecoveryPolicy instanceof LastImageSubscriptionRecoveryPolicy); LOG.info("destination: " + topic); LOG.info("dispatchPolicy: " + dispatchPolicy); LOG.info("subscriptionRecoveryPolicy: " + subscriptionRecoveryPolicy); topic = (Topic) broker.addDestination(context, new ActiveMQTopic("ORDERS.BOOKS"), true); dispatchPolicy = topic.getDispatchPolicy(); assertTrue("dispatchPolicy should be StrictOrderDispatchPolicy: " + dispatchPolicy, dispatchPolicy instanceof StrictOrderDispatchPolicy); subscriptionRecoveryPolicy = topic.getSubscriptionRecoveryPolicy(); subscriptionRecoveryPolicy = ((RetainedMessageSubscriptionRecoveryPolicy) subscriptionRecoveryPolicy).getWrapped(); assertTrue("subscriptionRecoveryPolicy should be TimedSubscriptionRecoveryPolicy: " + subscriptionRecoveryPolicy, subscriptionRecoveryPolicy instanceof TimedSubscriptionRecoveryPolicy); TimedSubscriptionRecoveryPolicy timedSubscriptionPolicy = (TimedSubscriptionRecoveryPolicy) subscriptionRecoveryPolicy; assertEquals("getRecoverDuration()", 60000, timedSubscriptionPolicy.getRecoverDuration()); LOG.info("destination: " + topic); LOG.info("dispatchPolicy: " + dispatchPolicy); LOG.info("subscriptionRecoveryPolicy: " + subscriptionRecoveryPolicy); }
Example #22
Source File: SimpleAuthenticationPluginSeparatorTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * @see {@link org.apache.activemq.CombinationTestSupport} */ @Override public void initCombosForTestUserSendSucceeds() { addCombinationValues("userName", new Object[]{"user"}); addCombinationValues("password", new Object[]{"password"}); addCombinationValues("destination", new Object[]{new ActiveMQQueue("USERS/FOO"), new ActiveMQQueue("GUEST/BAR"), new ActiveMQTopic("USERS/FOO"), new ActiveMQTopic("GUEST/BAR")}); }
Example #23
Source File: SimpleAuthenticationPluginSeparatorTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * @see {@link org.apache.activemq.CombinationTestSupport} */ @Override public void initCombosForTestUserSendFails() { addCombinationValues("userName", new Object[]{"user"}); addCombinationValues("password", new Object[]{"password"}); addCombinationValues("destination", new Object[]{new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST")}); }
Example #24
Source File: RemoveDestinationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private boolean destinationPresentInAdminView(ActiveMQTopic amqTopic) throws Exception { boolean found = false; ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker(); PostOffice po = wrapper.getServer().getPostOffice(); Set<SimpleString> addressSet = po.getAddresses(); Iterator<SimpleString> iter = addressSet.iterator(); String addressToFind = amqTopic.getPhysicalName(); while (iter.hasNext()) { if (addressToFind.equals(iter.next().toString())) { found = true; break; } } return found; }
Example #25
Source File: ActiveMQAdmin.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void createTopic(String name) { try { context.bind(name, new ActiveMQTopic(name)); } catch (NamingException e) { throw new RuntimeException(e); } }
Example #26
Source File: TopicSubscriptionZeroPrefetchTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testTopicConsumerPrefetchZero() throws Exception { ActiveMQTopic consumerDestination = new ActiveMQTopic(TOPIC_NAME + "?consumer.retroactive=true&consumer.prefetchSize=0"); consumer = session.createConsumer(consumerDestination); // publish messages Message txtMessage = session.createTextMessage("M"); producer.send(txtMessage); Message consumedMessage = consumer.receiveNoWait(); Assert.assertNotNull("should have received a message the published message", consumedMessage); }
Example #27
Source File: NetworkBridgeProducerFlowControlTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testSendFailIfNoSpaceDoesNotBlockTopicNetwork() throws Exception { // Consumer prefetch is disabled for broker1's consumers. final ActiveMQTopic SLOW_SHARED_TOPIC = new ActiveMQTopic(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".slow.shared?consumer.prefetchSize=1"); final ActiveMQTopic FAST_SHARED_TOPIC = new ActiveMQTopic(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".fast.shared?consumer.prefetchSize=1"); doTestSendFailIfNoSpaceDoesNotBlockNetwork(SLOW_SHARED_TOPIC, FAST_SHARED_TOPIC); }
Example #28
Source File: DurableSubscriptionSelectorTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { setAutoFail(true); super.setUp(); startBroker(true); topic = (ActiveMQTopic) createDestination(); mbs = ManagementFactory.getPlatformMBeanServer(); }
Example #29
Source File: PeerTransportTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected ActiveMQDestination createDestination(String name) { if (topic) { return new ActiveMQTopic(name); } else { return new ActiveMQQueue(name); } }
Example #30
Source File: DurableSubsOfflineSelectorIndexUseTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { exceptions.clear(); topic = (ActiveMQTopic) createDestination(); createBroker(); super.setUp(); }