Package org.activemq

Examples of org.activemq.ActiveMQConnectionFactory


     * @return Connection - broker connection.
     */
    private static Connection createConnectionFactory(String url,
                                                     boolean embeddedBroker) throws JMSException {
        //Used to create a session from the default MQ server ActiveMQConnectionFactory.
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);

        if (embeddedBroker) {
            factory.setUseEmbeddedBroker(true);
        }

        factory.setTurboBoost(true);
        ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();

        c.getPrefetchPolicy().setQueuePrefetch(1000);
        c.getPrefetchPolicy().setQueueBrowserPrefetch(1000);
        c.getPrefetchPolicy().setTopicPrefetch(1000);
        c.getPrefetchPolicy().setDurableTopicPrefetch(1000);
View Full Code Here


        }
    }

    private static JmsTemplate createTemplate(String destinationName) {

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setBrokerURL(BROKER_URL);

        IdGenerator idGenerator = new IdGenerator();
        connectionFactory.setClientID(idGenerator.generateId());

        JmsTemplate jt = new JmsTemplate(connectionFactory);
        if (destinationName.startsWith("topic")) {
            jt.setPubSubDomain(true);
        }
View Full Code Here

public class InitialContextTest extends TestCase {
    public void testInitialContext() throws Exception {
        InitialContext context = new InitialContext();
        assertTrue("Created context", context != null);

        ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory");

        assertTrue("Should have created a ConnectionFactory", connectionFactory != null);

        System.out.println("Created with brokerURL: " + connectionFactory.getBrokerURL());

    }
View Full Code Here

        properties.put(Context.PROVIDER_URL, expected);

        InitialContext context = new InitialContext(properties);
        assertTrue("Created context", context != null);

        ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory");

        assertTrue("Should have created a ConnectionFactory", connectionFactory != null);

        assertEquals("the brokerURL should match", expected, connectionFactory.getBrokerURL());
    }
View Full Code Here

   
    if( fsContext == null ){
      return;
        }
   
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory();
    fsContext.rebind("ConnectionFactory", cf);
    Object lookup = fsContext.lookup("ConnectionFactory");
    assertTrue(lookup != null);
    assertTrue(lookup instanceof ActiveMQConnectionFactory);
  }
View Full Code Here

    public static void initContext(ServletContext context) {
        factory = initConnectionFactory(context);
        if (factory == null) {
            log.warn("No ConnectionFactory available in the ServletContext for: " + connectionFactoryAttribute);
            factory = new ActiveMQConnectionFactory("vm://localhost");
            context.setAttribute(connectionFactoryAttribute, factory);
        }
        queueConsumers = initQueueConsumers(context);
    }
View Full Code Here

            }

            boolean embeddedBroker = MessageServletSupport.asBoolean(servletContext.getInitParameter(embeddedBrokerInitParam));
            servletContext.log("Use embedded broker: " + embeddedBroker);

            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURL);
            factory.setUseEmbeddedBroker(embeddedBroker);

            connectionFactory = factory;
            servletContext.setAttribute(connectionFactoryAttribute, connectionFactory);
        }
        return connectionFactory;
View Full Code Here

     * @return Connection - broker connection.
     */
    private static Connection createConnectionFactory(String url,
                                                      boolean embeddedBroker) throws JMSException {
        //Used to create a session from the default MQ server ActiveMQConnectionFactory.
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);

        if (embeddedBroker) {
            factory.setUseEmbeddedBroker(true);
        }

        factory.setTurboBoost(true);
        ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();

        c.getPrefetchPolicy().setQueuePrefetch(1000);
        c.getPrefetchPolicy().setQueueBrowserPrefetch(1000);
        c.getPrefetchPolicy().setTopicPrefetch(1000);
        c.getPrefetchPolicy().setDurableTopicPrefetch(1000);
View Full Code Here

            BrokerContainerFactory brokerContainerFactory = XmlConfigHelper.createBrokerContainerFactory(getBrokerXmlConfig());

            IdGenerator idgen = new IdGenerator();
            container = brokerContainerFactory.createBrokerContainer(idgen.generateId(), BrokerContext.getInstance());
            container.start();
            connectionFactory = new ActiveMQConnectionFactory(container, getServerUrl());
        } catch (JMSException e) {
            log.error(e.toString(), e);
            throw new ResourceAdapterInternalException("Failed to startup an embedded broker", e);
        }
    }
View Full Code Here

    /**
     */
    public ActiveMQConnection makeConnection() throws JMSException {

        ActiveMQConnectionFactory connectionFactory = getConnectionFactory();

        String userName = info.getUserName();
        String password = info.getPassword();
        ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName, password);

        String clientId = info.getClientid();
        if (clientId != null) {
            physicalConnection.setClientID(clientId);
        }
View Full Code Here

TOP

Related Classes of org.activemq.ActiveMQConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.