Package org.hornetq.jms.server.embedded

Examples of org.hornetq.jms.server.embedded.EmbeddedJMS


   private EmbeddedJMS jms;

   public void contextInitialized(ServletContextEvent contextEvent)
   {
      ServletContext context = contextEvent.getServletContext();
      jms = new EmbeddedJMS();
      jms.setRegistry(new ServletContextBindingRegistry(context));
      try
      {
         jms.start();
      }
View Full Code Here


public class EmbeddedRestHornetQJMS extends EmbeddedRestHornetQ
{
   @Override
   protected void initEmbeddedHornetQ()
   {
      embeddedHornetQ = new EmbeddedJMS();
   }
View Full Code Here

   public static void main(final String[] args)
   {
      try
      {
         EmbeddedJMS jmsServer = new EmbeddedJMS();
         jmsServer.start();
         System.out.println("Started Embedded JMS Server");

         ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("/cf");
         Queue queue = (Queue)jmsServer.lookup("/queue/exampleQueue");

         // Step 10. Send and receive a message using JMS API
         Connection connection = null;
         try
         {
            connection = cf.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello sent at " + new Date());
            System.out.println("Sending message: " + message.getText());
            producer.send(message);
            MessageConsumer messageConsumer = session.createConsumer(queue);
            connection.start();
            TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000);
            System.out.println("Received message:" + messageReceived.getText());
         }
         finally
         {
            if (connection != null)
            {
               connection.close();
            }

            // Step 11. Stop the JMS server
            jmsServer.stop();
            System.out.println("Stopped the JMS Server");
            System.exit(0);
         }
      }
      catch (Exception e)
View Full Code Here

         // Step 4. Configure the JMS Queue
         JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl("queue1", null, false, "/queue/queue1");
         jmsConfig.getQueueConfigurations().add(queueConfig);

         // Step 5. Start the JMS Server using the HornetQ core server and the JMS configuration
         EmbeddedJMS jmsServer = new EmbeddedJMS();
         jmsServer.setConfiguration(configuration);
         jmsServer.setJmsConfiguration(jmsConfig);
         jmsServer.start();
         System.out.println("Started Embedded JMS Server");

         // Step 6. Lookup JMS resources defined in the configuration
         ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("/cf");
         Queue queue = (Queue)jmsServer.lookup("/queue/queue1");

         // Step 7. Send and receive a message using JMS API
         Connection connection = null;
         try
         {
            connection = cf.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello sent at " + new Date());
            System.out.println("Sending message: " + message.getText());
            producer.send(message);
            MessageConsumer messageConsumer = session.createConsumer(queue);
            connection.start();
            TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000);
            System.out.println("Received message:" + messageReceived.getText());
         }
         finally
         {
            if (connection != null)
            {
               connection.close();
            }

            // Step 11. Stop the JMS server
            jmsServer.stop();
            System.out.println("Stopped the JMS Server");

            System.exit(0);
         }
      }
View Full Code Here

   
    @Override
    public void initialize() {
        super.initialize();
        if (_startEmbedded) {
            _embeddedJMS = new EmbeddedJMS();
            _embeddedJMS.setConfigResourcePath(HORNETQ_CONF_FILE);
            _embeddedJMS.setJmsConfigResourcePath(HORNETQ_JMS_CONF_FILE);
            try {
                _embeddedJMS.setRegistry(new JndiBindingRegistry());
                _embeddedJMS.start();
View Full Code Here

         {
            ignored.printStackTrace();
         }
         try
         {
            EmbeddedJMS jms = (EmbeddedJMS)context.getBean("EmbeddedJms");
            jms.stop();
         }
         catch (Throwable ignored)
         {
            ignored.printStackTrace();
         }
View Full Code Here

      }
      finally
      {
         try
         {
            EmbeddedJMS jms = (EmbeddedJMS)context.getBean("EmbeddedJms");
            jms.stop();
         }
         catch (Throwable ignored)
         {
            ignored.printStackTrace();
         }
View Full Code Here

         {
            ignored.printStackTrace();
         }
         try
         {
            EmbeddedJMS jms = (EmbeddedJMS)context.getBean("EmbeddedJms");
            jms.stop();
         }
         catch (Throwable ignored)
         {
            ignored.printStackTrace();
         }
View Full Code Here

         // Step 4. Configure the JMS Queue
         JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl("queue1", null, false, "/queue/queue1");
         jmsConfig.getQueueConfigurations().add(queueConfig);

         // Step 5. Start the JMS Server using the HornetQ core server and the JMS configuration
         EmbeddedJMS jmsServer = new EmbeddedJMS();
         jmsServer.setConfiguration(configuration);
         jmsServer.setJmsConfiguration(jmsConfig);
         jmsServer.start();
         System.out.println("Started Embedded JMS Server");

         // Step 6. Lookup JMS resources defined in the configuration
         ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("/cf");
         Queue queue = (Queue)jmsServer.lookup("/queue/queue1");

         // Step 7. Send and receive a message using JMS API
         Connection connection = null;
         try
         {
            connection = cf.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello sent at " + new Date());
            System.out.println("Sending message: " + message.getText());
            producer.send(message);
            MessageConsumer messageConsumer = session.createConsumer(queue);
            connection.start();
            TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000);
            System.out.println("Received message:" + messageReceived.getText());
         }
         finally
         {
            if (connection != null)
            {
               connection.close();
            }

            // Step 11. Stop the JMS server
            jmsServer.stop();
            System.out.println("Stopped the JMS Server");

            System.exit(0);
         }
      }
View Full Code Here

   public static void main(final String[] args)
   {
      try
      {
         EmbeddedJMS jmsServer = new EmbeddedJMS();
         jmsServer.start();
         System.out.println("Started Embedded JMS Server");

         ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("/cf");
         Queue queue = (Queue)jmsServer.lookup("/queue/exampleQueue");

         // Step 10. Send and receive a message using JMS API
         Connection connection = null;
         try
         {
            connection = cf.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);
            TextMessage message = session.createTextMessage("Hello sent at " + new Date());
            System.out.println("Sending message: " + message.getText());
            producer.send(message);
            MessageConsumer messageConsumer = session.createConsumer(queue);
            connection.start();
            TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000);
            System.out.println("Received message:" + messageReceived.getText());
         }
         finally
         {
            if (connection != null)
            {
               connection.close();
            }

            // Step 11. Stop the JMS server
            jmsServer.stop();
            System.out.println("Stopped the JMS Server");
            System.exit(0);
         }
      }
      catch (Exception e)
View Full Code Here

TOP

Related Classes of org.hornetq.jms.server.embedded.EmbeddedJMS

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.