Package javax.jms

Examples of javax.jms.TemporaryQueue


      getLog().debug("Starting InvalidDestinationQueueBrowse test");
      connect();

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();
      QueueBrowser browser = session.createBrowser(queue);
      queue.delete();

      boolean caught = false;
      try
      {
         browser.getEnumeration();
View Full Code Here


     
      Connection conn = cf2.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      TemporaryQueue queue = sess.createTemporaryQueue();
     
      MessageProducer prod = sess.createProducer(queue);
     
      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
          
View Full Code Here


   public void testJMSDestinationSimple() throws Exception
   {
      Message m = queueProducerSession.createMessage();
      TemporaryQueue tempQ = queueProducerSession.createTemporaryQueue();
      m.setJMSReplyTo(tempQ);
     
      queueProducer.send(m);
      queueConsumer.receive();
      assertEquals(tempQ, m.getJMSReplyTo());
View Full Code Here

      if (command.getReplyTimeout() > 0) {

        // we have to wait an execution reply for an hardware device or
        // an external client
        final Session unlistenedSession = this.getUnlistenedSession();
        TemporaryQueue temporaryQueue = unlistenedSession
            .createTemporaryQueue();
        // TODO where this TemporaryQueue is delete? Should it be?

        msg.setJMSReplyTo(temporaryQueue);
View Full Code Here

    Session producerSession = null;
    Queue producerQueue = null;
    MessageProducer producer;
    MessageConsumer consumer;
    Session consumerSession = null;
    TemporaryQueue consumerDestination = null;
    long startTime = 0;

    //  Check if JMX server port number was specified
    jmxPort = System.getProperty("activemq.broker.jmx.port");
    if ( jmxPort == null || jmxPort.trim().length() == 0 ) {
      jmxPort = "1099"// default
    }

    try {
      //  First create connection to a broker
      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURI);
      connection = factory.createConnection();
      connection.start();
      Runtime.getRuntime().addShutdownHook(
         new Thread(
              new Runnable() {
                  public void run() {
                    try {
                        if ( connection != null ) {
                          connection.close();
                        }
                        if ( jmxc != null ) {
                          jmxc.close();
                        }
                    } catch( Exception ex) {
                    }
                  }      
              }
         )
      );
     
      URI target = new URI(brokerURI);
      String brokerHost = target.getHost();

      attachToRemoteBrokerJMXServer(brokerURI);
      if (isQueueAvailable(queueName) == QueueState.exists) {
        System.out.println("Queue "+queueName+" found on "+ brokerURI);
        System.out.println("Sending getMeta...");
      }
      else if (isQueueAvailable(queueName) == QueueState.existsnot) {
        System.err.println("Queue "+queueName+" does not exist on "+ brokerURI);
        System.exit(1);
      }
      else {
        System.out.println("Cannot see queues on JMX port "+brokerHost+":"+jmxPort);
        System.out.println("Sending getMeta anyway...");
      }

      producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      producerQueue = producerSession.createQueue(queueName);
      producer = producerSession.createProducer(producerQueue);
      consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      consumerDestination = consumerSession.createTemporaryQueue();
      //  -----------------------------------------------------------------------------
      //  Create message consumer. The consumer uses a selector to filter out messages other
      //  then GetMeta replies. Currently UIMA AS service returns two messages for each request:
      //  ServiceInfo message and GetMeta message. The ServiceInfo message is returned by the
      //  service immediately upon receiving a message from a client. This serves dual purpose,
      //  1) to make sure the client reply destination exists
      //  2) informs the client which service is processing its request
      //  -----------------------------------------------------------------------------
      consumer = consumerSession.createConsumer(consumerDestination, "Command=2001");
      TextMessage msg = producerSession.createTextMessage();
      msg.setStringProperty(AsynchAEMessage.MessageFrom, consumerDestination.getQueueName());
      msg.setStringProperty(UIMAMessage.ServerURI, brokerURI);
      msg.setIntProperty(AsynchAEMessage.MessageType, AsynchAEMessage.Request);
      msg.setIntProperty(AsynchAEMessage.Command, AsynchAEMessage.GetMeta);
      msg.setJMSReplyTo(consumerDestination);
      msg.setText("");
View Full Code Here

        answer.setDestinationName("temporary");
        answer.setDestinationResolver(new DestinationResolver() {

            public Destination resolveDestinationName(Session session, String destinationName,
                                                      boolean pubSubDomain) throws JMSException {
                TemporaryQueue queue = null;
                synchronized (getOutterInstance()) {
                    try {
                        queue = session.createTemporaryQueue();
                        setReplyTo(queue);
                    } finally {
View Full Code Here

   * @param requestMessage the JMS Message to send
   * @return the RemoteInvocationResult object
   * @throws JMSException in case of JMS failure
   */
  protected Message doExecuteRequest(Session session, Queue queue, Message requestMessage) throws JMSException {
    TemporaryQueue responseQueue = null;
    MessageProducer producer = null;
    MessageConsumer consumer = null;
    try {
      if (jms11Available) {
        // Standard JMS 1.1 API usage...
        responseQueue = session.createTemporaryQueue();
        producer = session.createProducer(queue);
        consumer = session.createConsumer(responseQueue);
        requestMessage.setJMSReplyTo(responseQueue);
        producer.send(requestMessage);
      }
      else {
        // Perform all calls on QueueSession reference for JMS 1.0.2 compatibility...
        // DEPRECATED but kept around with the deprecated JmsTemplate102 etc classes for the time being.
        QueueSession queueSession = (QueueSession) session;
        responseQueue = queueSession.createTemporaryQueue();
        QueueSender sender = queueSession.createSender(queue);
        producer = sender;
        consumer = queueSession.createReceiver(responseQueue);
        requestMessage.setJMSReplyTo(responseQueue);
        sender.send(requestMessage);
      }
      long timeout = getReceiveTimeout();
      return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
    }
    finally {
      JmsUtils.closeMessageConsumer(consumer);
      JmsUtils.closeMessageProducer(producer);
      if (responseQueue != null) {
        responseQueue.delete();
      }
    }
  }
View Full Code Here

        answer.setDestinationName("temporary");
        answer.setDestinationResolver(new DestinationResolver() {
            public Destination resolveDestinationName(Session session, String destinationName,
                                                      boolean pubSubDomain) throws JMSException {
                // use a temporary queue to gather the reply message
                TemporaryQueue queue = session.createTemporaryQueue();
                setReplyTo(queue);
                return queue;
            }
        });
        answer.setAutoStartup(true);
View Full Code Here

   * @throws JMSException in case of JMS failure
   */
  protected Message doExecuteRequest(
      QueueSession session, Queue queue, Message requestMessage) throws JMSException {

    TemporaryQueue responseQueue = null;
    QueueSender sender = null;
    QueueReceiver receiver = null;
    try {
      responseQueue = session.createTemporaryQueue();
      sender = session.createSender(queue);
      receiver = session.createReceiver(responseQueue);
      requestMessage.setJMSReplyTo(responseQueue);
      sender.send(requestMessage);
      long timeout = getReceiveTimeout();
      return (timeout > 0 ? receiver.receive(timeout) : receiver.receive());
    }
    finally {
      JmsUtils.closeMessageConsumer(receiver);
      JmsUtils.closeMessageProducer(sender);
      if (responseQueue != null) {
        responseQueue.delete();
      }
    }
  }
View Full Code Here

   * @param requestMessage the JMS Message to send
   * @return the RemoteInvocationResult object
   * @throws JMSException in case of JMS failure
   */
  protected Message doExecuteRequest(Session session, Queue queue, Message requestMessage) throws JMSException {
    TemporaryQueue responseQueue = null;
    MessageProducer producer = null;
    MessageConsumer consumer = null;
    try {
      if (session instanceof QueueSession) {
        // Perform all calls on QueueSession reference for JMS 1.0.2 compatibility...
        QueueSession queueSession = (QueueSession) session;
        responseQueue = queueSession.createTemporaryQueue();
        QueueSender sender = queueSession.createSender(queue);
        producer = sender;
        consumer = queueSession.createReceiver(responseQueue);
        requestMessage.setJMSReplyTo(responseQueue);
        sender.send(requestMessage);
      }
      else {
        // Standard JMS 1.1 API usage...
        responseQueue = session.createTemporaryQueue();
        producer = session.createProducer(queue);
        consumer = session.createConsumer(responseQueue);
        requestMessage.setJMSReplyTo(responseQueue);
        producer.send(requestMessage);
      }
      long timeout = getReceiveTimeout();
      return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
    }
    finally {
      JmsUtils.closeMessageConsumer(consumer);
      JmsUtils.closeMessageProducer(producer);
      if (responseQueue != null) {
        responseQueue.delete();
      }
    }
  }
View Full Code Here

TOP

Related Classes of javax.jms.TemporaryQueue

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.