Java Code Examples for org.apache.activemq.ActiveMQConnection#DEFAULT_BROKER_URL

The following examples show how to use org.apache.activemq.ActiveMQConnection#DEFAULT_BROKER_URL . 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: AcknowledgementExample.java    From scava with Eclipse Public License 2.0 7 votes vote down vote up
public void run() throws Exception {
	BrokerService broker = new BrokerService();
	broker.setUseJmx(true);
	broker.setPersistent(false);
	broker.addConnector("tcp://localhost:61616");
	broker.start();
	
	ActiveMQConnectionFactory connectionFactory = 
			new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
	ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
	connection.start();
	
	ActiveMQSession session = (ActiveMQSession) connection.
			createSession(false, ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE);
	Queue queue = session.createQueue("queue");
	
	createConsumer(session, queue, "Consumer 1", false);
	createConsumer(session, queue, "Consumer 2", true);
	
	MessageProducer producer = session.createProducer(queue);
	for (int i=0;i<10;i++) {
		producer.send(session.createTextMessage("Message " + i));
		Thread.sleep(100);
	}
	
}
 
Example 2
Source File: Consumer.java    From jms with MIT License 6 votes vote down vote up
public void create(String clientId, String queueName)
    throws JMSException {
  this.clientId = clientId;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  Session session =
      connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

  // create the Queue from which messages will be received
  Queue queue = session.createQueue(queueName);

  // create a MessageConsumer for receiving messages
  messageConsumer = session.createConsumer(queue);

  // start the connection in order to receive messages
  connection.start();
}
 
Example 3
Source File: Producer.java    From jms with MIT License 6 votes vote down vote up
public void create(String clientId, String queueName)
    throws JMSException {
  this.clientId = clientId;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  session =
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

  // create the Queue to which messages will be sent
  Queue queue = session.createQueue(queueName);

  // create a MessageProducer for sending messages
  messageProducer = session.createProducer(queue);
}
 
Example 4
Source File: Publisher.java    From jms with MIT License 6 votes vote down vote up
public void create(String clientId, String topicName)
    throws JMSException {
  this.clientId = clientId;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  session =
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

  // create the Topic to which messages will be sent
  Topic topic = session.createTopic(topicName);

  // create a MessageProducer for sending messages
  messageProducer = session.createProducer(topic);
}
 
Example 5
Source File: Subscriber.java    From jms with MIT License 6 votes vote down vote up
public void create(String clientId, String topicName)
    throws JMSException {
  this.clientId = clientId;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  Session session =
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

  // create the Topic from which messages will be received
  Topic topic = session.createTopic(topicName);

  // create a MessageConsumer for receiving messages
  messageConsumer = session.createConsumer(topic);

  // start the connection in order to receive messages
  connection.start();
}
 
Example 6
Source File: UnidentifiedProducer.java    From jms with MIT License 6 votes vote down vote up
public void create() throws JMSException {

    // create a Connection Factory
    ConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory(
            ActiveMQConnection.DEFAULT_BROKER_URL);

    // create a Connection
    connection = connectionFactory.createConnection();

    // create a Session
    session =
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // create a Message Producer for sending messages
    messageProducer = session.createProducer(null);
  }
 
Example 7
Source File: Consumer.java    From jms with MIT License 6 votes vote down vote up
public void create(String destinationName) throws JMSException {

    // create a Connection Factory
    ConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory(
            ActiveMQConnection.DEFAULT_BROKER_URL);

    // create a Connection
    connection = connectionFactory.createConnection();

    // create a Session
    Session session =
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // create the Destination from which messages will be received
    Destination destination = session.createQueue(destinationName);

    // create a Message Consumer for receiving messages
    messageConsumer = session.createConsumer(destination);

    // start the connection in order to receive messages
    connection.start();
  }
 
Example 8
Source File: Producer.java    From jms with MIT License 6 votes vote down vote up
public void create(String destinationName) throws JMSException {

    // create a Connection Factory
    ConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory(
            ActiveMQConnection.DEFAULT_BROKER_URL);

    // create a Connection
    connection = connectionFactory.createConnection();

    // create a Session
    session =
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // create the Destination to which messages will be sent
    Destination destination = session.createQueue(destinationName);

    // create a Message Producer for sending messages
    messageProducer = session.createProducer(destination);
  }
 
Example 9
Source File: Producer.java    From jms with MIT License 5 votes vote down vote up
public void openConnection() throws JMSException {
  // Create a new connection factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);
  connection = connectionFactory.createConnection();
}
 
Example 10
Source File: DurableSubscriber.java    From jms with MIT License 5 votes vote down vote up
public void create(String clientId, String topicName,
    String subscriptionName) throws JMSException {
  this.clientId = clientId;
  this.subscriptionName = subscriptionName;

  // create a Connection Factory
  ConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory(
          ActiveMQConnection.DEFAULT_BROKER_URL);

  // create a Connection
  connection = connectionFactory.createConnection();
  connection.setClientID(clientId);

  // create a Session
  session =
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

  // create the Topic from which messages will be received
  Topic topic = session.createTopic(topicName);

  // create a MessageConsumer for receiving messages
  messageConsumer =
      session.createDurableSubscriber(topic, subscriptionName);

  // start the connection in order to receive messages
  connection.start();
}
 
Example 11
Source File: ConnectionChurnTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
   return cf;
}
 
Example 12
Source File: AdvisoryTempDestinationTests.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
   return cf;
}
 
Example 13
Source File: AdvisoryTests.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
   ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
   return cf;
}