Java Code Examples for org.apache.activemq.broker.TransportConnector#getConnectUri()
The following examples show how to use
org.apache.activemq.broker.TransportConnector#getConnectUri() .
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: QueueBrowsingTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Before public void startBroker() throws Exception { broker = createBroker(); TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0"); broker.deleteAllMessages(); broker.start(); broker.waitUntilStarted(); PolicyEntry policy = new PolicyEntry(); policy.setMaxPageSize(maxPageSize); broker.setDestinationPolicy(new PolicyMap()); broker.getDestinationPolicy().setDefaultEntry(policy); connectUri = connector.getConnectUri(); factory = new ActiveMQConnectionFactory(connectUri); }
Example 2
Source File: QueueBrowsingLimitTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Before public void startBroker() throws Exception { broker = createBroker(); TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0"); broker.deleteAllMessages(); broker.start(); broker.waitUntilStarted(); PolicyEntry policy = new PolicyEntry(); policy.setMaxBrowsePageSize(browserLimit); broker.setDestinationPolicy(new PolicyMap()); broker.getDestinationPolicy().setDefaultEntry(policy); connectUri = connector.getConnectUri(); factory = new ActiveMQConnectionFactory(connectUri); }
Example 3
Source File: SslContextNBrokerServiceTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private boolean verifySslCredentials(BrokerService broker) throws Exception { TransportConnector connector = broker.getTransportConnectors().get(0); URI brokerUri = connector.getConnectUri(); SSLContext context = SSLContext.getInstance("TLS"); CertChainCatcher catcher = new CertChainCatcher(); context.init(null, new TrustManager[]{catcher}, null); SSLSocketFactory factory = context.getSocketFactory(); LOG.info("Connecting to broker: " + broker.getBrokerName() + " on: " + brokerUri.getHost() + ":" + brokerUri.getPort()); SSLSocket socket = (SSLSocket) factory.createSocket(brokerUri.getHost(), brokerUri.getPort()); socket.setSoTimeout(2 * 60 * 1000); socket.startHandshake(); socket.close(); boolean matches = false; if (catcher.serverCerts != null) { for (int i = 0; i < catcher.serverCerts.length; i++) { X509Certificate cert = catcher.serverCerts[i]; LOG.info(" " + (i + 1) + " Issuer " + cert.getIssuerDN()); } if (catcher.serverCerts.length > 0) { String issuer = catcher.serverCerts[0].getIssuerDN().toString(); if (issuer.indexOf(broker.getBrokerName()) != -1) { matches = true; } } } return matches; }
Example 4
Source File: ConsumeUncompressedCompressedMessageTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected BrokerService createBroker(boolean delete) throws Exception { BrokerService answer = new BrokerService(); answer.setPersistent(false); answer.setDeleteAllMessagesOnStartup(true); answer.setSchedulerSupport(false); answer.setUseJmx(true); TransportConnector connector = answer.addConnector("tcp://localhost:0"); tcpUri = connector.getConnectUri(); return answer; }
Example 5
Source File: AbstractElasticSearchActiveMQTest.java From camunda-bpm-elasticsearch with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { broker = createBroker(); connector = new TransportConnector(); connector.setUri(new URI("vm://localhost")); broker.addConnector(connector); broker.start(); ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory(connector.getConnectUri() + "?jms.prefetchPolicy.all=1"); connection = connFactory.createConnection(); connection.start(); }
Example 6
Source File: TwoBrokerTempQueueAdvisoryTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void testSendToRemovedTemp() throws Exception { ActiveMQQueue requestReplyDest = new ActiveMQQueue("RequestReply"); NetworkConnector nc = bridgeBrokers("BrokerA", "BrokerB"); if (useDuplex) { nc.setDuplex(true); } else { bridgeBrokers("BrokerB", "BrokerA"); } // destination advisory can loose the race with message dispatch, so we need to allow replies on network broker // to work in the absence of an advisory, the destination will be cleaned up in the normal // way if (!useDuplex) { brokers.get("BrokerB").broker.setAllowTempAutoCreationOnSend(true); } TransportConnector forClient = brokers.get("BrokerA").broker.addConnector("tcp://localhost:0"); startAllBrokers(); waitForBridgeFormation(); waitForMinTopicRegionConsumerCount("BrokerB", 1); waitForMinTopicRegionConsumerCount("BrokerA", 1); ConnectionFactory factory = new ActiveMQConnectionFactory(forClient.getConnectUri()); ActiveMQConnection conn = (ActiveMQConnection) factory.createConnection(); conn.setWatchTopicAdvisories(false); conn.start(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); ConnectionFactory replyFactory = getConnectionFactory("BrokerB"); for (int i = 0; i < 500; i++) { TemporaryQueue tempDest = session.createTemporaryQueue(); MessageProducer producer = session.createProducer(requestReplyDest); javax.jms.Message message = session.createTextMessage("req-" + i); message.setJMSReplyTo(tempDest); ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(tempDest); producer.send(message); ActiveMQConnection replyConnection = (ActiveMQConnection) replyFactory.createConnection(); replyConnection.setWatchTopicAdvisories(false); replyConnection.start(); Session replySession = replyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQMessageConsumer replyConsumer = (ActiveMQMessageConsumer) replySession.createConsumer(requestReplyDest); javax.jms.Message msg = replyConsumer.receive(10000); assertNotNull("request message not null: " + i, msg); MessageProducer replyProducer = replySession.createProducer(msg.getJMSReplyTo()); replyProducer.send(session.createTextMessage("reply-" + i)); replyConnection.close(); javax.jms.Message reply = consumer.receive(10000); assertNotNull("reply message : " + i + ", to: " + tempDest + ", by consumer:" + consumer.getConsumerId(), reply); consumer.close(); tempDest.delete(); } }
Example 7
Source File: TimeStampTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void test() throws Exception { BrokerService broker = new BrokerService(); broker.setPersistent(false); broker.setUseJmx(true); broker.setPlugins(new BrokerPlugin[]{new ConnectionDotFilePlugin(), new UDPTraceBrokerPlugin()}); TransportConnector tcpConnector = broker.addConnector("tcp://localhost:0"); broker.addConnector("stomp://localhost:0"); broker.start(); // Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(tcpConnector.getConnectUri()); // Create a Connection Connection connection = connectionFactory.createConnection(); connection.start(); // Create a Session Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create the destination Queue Destination destination = session.createQueue("TEST.FOO"); // Create a MessageProducer from the Session to the Topic or Queue MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // Create a messages Message sentMessage = session.createMessage(); // Tell the producer to send the message long beforeSend = System.currentTimeMillis(); producer.send(sentMessage); long afterSend = System.currentTimeMillis(); // assert message timestamp is in window assertTrue(beforeSend <= sentMessage.getJMSTimestamp() && sentMessage.getJMSTimestamp() <= afterSend); // Create a MessageConsumer from the Session to the Topic or Queue MessageConsumer consumer = session.createConsumer(destination); // Wait for a message Message receivedMessage = consumer.receive(1000); // assert we got the same message ID we sent assertEquals(sentMessage.getJMSMessageID(), receivedMessage.getJMSMessageID()); // assert message timestamp is in window assertTrue("JMS Message Timestamp should be set during the send method: \n" + " beforeSend = " + beforeSend + "\n" + " getJMSTimestamp = " + receivedMessage.getJMSTimestamp() + "\n" + " afterSend = " + afterSend + "\n", beforeSend <= receivedMessage.getJMSTimestamp() && receivedMessage.getJMSTimestamp() <= afterSend); // assert message timestamp is unchanged assertEquals("JMS Message Timestamp of received message should be the same as the sent message\n ", sentMessage.getJMSTimestamp(), receivedMessage.getJMSTimestamp()); // Clean up producer.close(); consumer.close(); session.close(); connection.close(); }