Java Code Examples for org.apache.activemq.ActiveMQConnectionFactory#createQueueConnection()
The following examples show how to use
org.apache.activemq.ActiveMQConnectionFactory#createQueueConnection() .
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: JMXRemoveQueueThenSendIgnoredTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setBrokerName("dev"); brokerService.setPersistent(false); brokerService.setUseJmx(true); brokerService.addConnector("tcp://localhost:0"); brokerService.start(); final String brokerUri = brokerService.getTransportConnectors().get(0).getPublishableConnectString(); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(brokerUri); connection = activeMQConnectionFactory.createQueueConnection(); session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE/*SESSION_TRANSACTED*/); queue = session.createQueue("myqueue"); producer = session.createProducer(queue); producer.setDeliveryMode(DeliveryMode.PERSISTENT); connection.start(); }
Example 2
Source File: ActiveMQQueueReader.java From java-course-ee with MIT License | 6 votes |
public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "admin", "tcp://localhost:61616"); QueueConnection queueConnection = connectionFactory.createQueueConnection(); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = queueSession.createQueue("test-queue"); MessageConsumer consumer = queueSession.createConsumer(queue); queueConnection.start(); while(true) { log.info("Waiting for message..."); TextMessage message = (TextMessage) consumer.receive(); log.info("Message received with text: {} at time {}", message.getText(), System.currentTimeMillis()); } }
Example 3
Source File: MessageOrderingTest.java From olat with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL("tcp://localhost:61616"); Connection connection = connectionFactory.createQueueConnection(); Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = new ActiveMQQueue("/atestqueue"); MessageProducer producer = session1.createProducer(destination); MessageConsumer consumer = session2.createConsumer(destination); consumer.setMessageListener(new MessageOrderingTest()); connection.start(); for (int i = 0; i < 10000; i++) { MapMessage message = session1.createMapMessage(); message.setInt("Counter", i); producer.send(message); System.out.println("Sent counter=" + i); } }
Example 4
Source File: MessageOrderingTest.java From olat with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); connectionFactory.setBrokerURL("tcp://localhost:61616"); Connection connection = connectionFactory.createQueueConnection(); Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = new ActiveMQQueue("/atestqueue"); MessageProducer producer = session1.createProducer(destination); MessageConsumer consumer = session2.createConsumer(destination); consumer.setMessageListener(new MessageOrderingTest()); connection.start(); for (int i = 0; i < 10000; i++) { MapMessage message = session1.createMapMessage(); message.setInt("Counter", i); producer.send(message); System.out.println("Sent counter=" + i); } }
Example 5
Source File: LDAPAuthenticationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testWildcard() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); Connection conn = factory.createQueueConnection("*", "sunflower"); try { conn.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (Exception e) { e.printStackTrace(); return; } fail("Should have failed connecting"); }
Example 6
Source File: QReceiverListener.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QReceiverListener() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = qSession.createQueue("test"); qReceiver = qSession.createReceiver(queue); qReceiver.setMessageListener(this); System.out.println("等待接受消息......"); } catch (Exception e) { e.printStackTrace(); } }
Example 7
Source File: CachedLDAPSecurityLegacyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSendDenied() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); Queue queue = sess.createQueue("ADMIN.FOO"); try { sess.createProducer(queue); fail("expect auth exception"); } catch (JMSException expected) { } }
Example 8
Source File: CachedLDAPSecurityLegacyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSendReceive() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); Queue queue = sess.createQueue("TEST.FOO"); MessageProducer producer = sess.createProducer(queue); MessageConsumer consumer = sess.createConsumer(queue); producer.send(sess.createTextMessage("test")); Message msg = consumer.receive(1000); assertNotNull(msg); }
Example 9
Source File: LDAPSecurityTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testTempDestinations() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); Queue queue = sess.createTemporaryQueue(); MessageProducer producer = sess.createProducer(queue); MessageConsumer consumer = sess.createConsumer(queue); producer.send(sess.createTextMessage("test")); Message msg = consumer.receive(1000); assertNotNull(msg); }
Example 10
Source File: LDAPSecurityTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testCompositeSendDenied() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); Queue queue = sess.createQueue("TEST.FOO,ADMIN.FOO"); try { MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("test")); fail("expect auth exception"); } catch (JMSException expected) { } }
Example 11
Source File: LDAPSecurityTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testSendDenied() throws Exception { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); Queue queue = sess.createQueue("ADMIN.FOO"); try { MessageProducer producer = sess.createProducer(queue); producer.send(sess.createTextMessage("test")); fail("expect auth exception"); } catch (JMSException expected) { } }
Example 12
Source File: InitConfServer.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
/** * 创建jms连接 * * @return * @throws JMSException */ private QueueConnection createSharedConnection() throws JMSException { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(MQADDRESS); QueueConnection connection = null; try { connection = factory.createQueueConnection(); } catch (JMSException e) { closeConnection(connection); throw e; } return connection; }
Example 13
Source File: MQWatcher.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
private QueueConnection createQueueConnection() throws JMSException { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(MQADDRESS); QueueConnection connection = null; try { connection = factory.createQueueConnection(); } catch (JMSException e) { closeConnection(connection); throw e; } return connection; }
Example 14
Source File: QReceiverListener.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QReceiverListener() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = qSession.createQueue("test"); qReceiver = qSession.createReceiver(queue); qReceiver.setMessageListener(this); System.out.println("等待接受消息......"); } catch (Exception e) { e.printStackTrace(); } }
Example 15
Source File: QReceiver.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QReceiver() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = qSession.createQueue("test"); qReceiver = qSession.createReceiver(queue); } catch (Exception e) { e.printStackTrace(); } }
Example 16
Source File: QReceiverListenerTransacted.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QReceiverListenerTransacted() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); queue = qSession.createQueue("test"); qReceiver = qSession.createReceiver(queue); qReceiver.setMessageListener(this); System.out.println("等待接受消息......"); } catch (Exception e) { e.printStackTrace(); } }
Example 17
Source File: QSenderTransacted.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QSenderTransacted() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); queue = qSession.createQueue("test"); qSender = qSession.createSender(queue); } catch (Exception e) { e.printStackTrace(); System.err.println("初始化生产者失败"); } }
Example 18
Source File: QReceiverListenerClient.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public QReceiverListenerClient() { try { factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); qConnection = factory.createQueueConnection(); qConnection.start(); qSession = qConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE); queue = qSession.createQueue("test"); qReceiver = qSession.createReceiver(queue); qReceiver.setMessageListener(this); System.out.println("等待接受消息......"); } catch (Exception e) { e.printStackTrace(); } }
Example 19
Source File: CreateTemporaryQueueBeforeStartTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected QueueConnection createConnection() throws Exception { ActiveMQConnectionFactory factory = createConnectionFactory(); return factory.createQueueConnection(); }
Example 20
Source File: PurgeCommandTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected void createConnections() throws JMSException { ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory"); localConnection = fac.createQueueConnection(); localConnection.start(); }