Package org.apache.activemq.command

Examples of org.apache.activemq.command.ActiveMQObjectMessage


   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQObjectMessage();
    }
View Full Code Here


   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQObjectMessage();
    }
View Full Code Here

        if (body instanceof String) {
            ActiveMQTextMessage answer = new ActiveMQTextMessage();
            answer.setText((String) body);
            return answer;
        } else if (body instanceof Serializable) {
            ActiveMQObjectMessage answer = new ActiveMQObjectMessage();
            answer.setObject((Serializable) body);
            return answer;
        } else {
            return new ActiveMQMessage();
        }
View Full Code Here

   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQObjectMessage();
    }
View Full Code Here

      Map<String, String> headers = new HashMap<String, String>(25);
      command.setHeaders(headers);

      FrameTranslator.Helper.copyStandardHeadersFromMessageToFrame(
          converter, message, command, this);
      ActiveMQObjectMessage msg = (ActiveMQObjectMessage) message.copy();
      command.setContent(marshall(msg.getObject(),
          headers.get(Stomp.Headers.TRANSFORMATION))
          .getBytes("UTF-8"));
      return command;

    } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) {
      StompFrame command = new StompFrame();
      command.setAction(Stomp.Responses.MESSAGE);
      Map<String, String> headers = new HashMap<String, String>(25);
      command.setHeaders(headers);

      FrameTranslator.Helper.copyStandardHeadersFromMessageToFrame(
          converter, message, command, this);
      ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy();
      command.setContent(marshall((Serializable)msg.getContentMap(),
          headers.get(Stomp.Headers.TRANSFORMATION))
          .getBytes("UTF-8"));
      return command;   
    } else {
      return super.convertMessage(converter, message);
View Full Code Here

    getXStream().marshal(object, out);
    return buffer.toString();
  }

  protected ActiveMQObjectMessage createObjectMessage(HierarchicalStreamReader in) throws JMSException {
    ActiveMQObjectMessage objMsg = new ActiveMQObjectMessage();
    Object obj = getXStream().unmarshal(in);
    objMsg.setObject((Serializable) obj);
    return objMsg;
  }
View Full Code Here

                    Connection connection = factory.createConnection();
                Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageConsumer consumer = session.createConsumer(destination);
                connection.start();
                    consumerStarted.countDown();
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)consumer.receive(30000);
                    if ( message != null ) {
                        MyObject object = (MyObject)message.getObject();
                        LOG.info("Got message " + object.getMessage());
                        numReceived.incrementAndGet();
                    }
          consumer.close();
        } catch (Throwable ex) {
          exceptions.add(ex);
        }
      }
    };
        vmConsumerThread.start();

    Thread producingThread = new Thread("Producing Thread") {
            public void run() {
                try {
                    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
                    factory.setOptimizedMessageDispatch(true);
                    factory.setObjectMessageSerializationDefered(true);
                    factory.setCopyMessageOnSend(false);

                    Connection connection = factory.createConnection();
                Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageProducer producer = session.createProducer(destination);
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)session.createObjectMessage();
                    message.setObject(obj);
                    producer.send(message);
                  producer.close();
                } catch (Throwable ex) {
                    exceptions.add(ex);
                }
View Full Code Here

                    Connection connection = factory.createConnection();
                Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageConsumer consumer = session.createConsumer(destination);
                connection.start();
                    consumerStarted.countDown();
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)consumer.receive(30000);
                    if ( message != null ) {                 
                        MyObject object = (MyObject)message.getObject();
                        LOG.info("Got message " + object.getMessage());
                        numReceived.incrementAndGet();
                    }
          consumer.close();
        } catch (Throwable ex) {
          exceptions.add(ex);
        }
      }
    };
        vmConsumerThread.start();

        Thread tcpConsumerThread = new Thread("Consumer Thread") {
      public void run() {
        try {

                    ActiveMQConnectionFactory factory =
                            new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
                    factory.setOptimizedMessageDispatch(true);

                    Connection connection = factory.createConnection();
                Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageConsumer consumer = session.createConsumer(destination);
                connection.start();
                    consumerStarted.countDown();
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)consumer.receive(30000);
                    if ( message != null ) {
                        MyObject object = (MyObject)message.getObject();
                        LOG.info("Got message " + object.getMessage());
                        numReceived.incrementAndGet();
                        assertEquals("readObject called", 1, object.getReadObjectCalled());
                    }
          consumer.close();
        } catch (Throwable ex) {
          exceptions.add(ex);
        }
      }
    };
        tcpConsumerThread.start();


        Thread notherVmConsumerThread = new Thread("Consumer Thread") {
            public void run() {
                try {
                    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
                    factory.setOptimizedMessageDispatch(true);
                    factory.setObjectMessageSerializationDefered(true);
                    factory.setCopyMessageOnSend(false);

                    Connection connection = factory.createConnection();
                    Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                    MessageConsumer consumer = session.createConsumer(destination);
                    connection.start();
                    consumerStarted.countDown();
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)consumer.receive(30000);
                    if ( message != null ) {
                        MyObject object = (MyObject)message.getObject();
                        LOG.info("Got message " + object.getMessage());
                        numReceived.incrementAndGet();
                    }
                    consumer.close();
                } catch (Throwable ex) {
                    exceptions.add(ex);
                }
            }
        };
        notherVmConsumerThread.start();

    Thread producingThread = new Thread("Producing Thread") {
            public void run() {
                try {
                    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
                    factory.setOptimizedMessageDispatch(true);
                    factory.setObjectMessageSerializationDefered(true);
                    factory.setCopyMessageOnSend(false);

                    Connection connection = factory.createConnection();
                Session session = (ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                MessageProducer producer = session.createProducer(destination);
                    ActiveMQObjectMessage message = (ActiveMQObjectMessage)session.createObjectMessage();
                    message.setObject(obj);
                    producer.send(message);
                  producer.close();
                } catch (Throwable ex) {
                    exceptions.add(ex);
                }
View Full Code Here

     * @return an ActiveMQObjectMessage
     * @throws JMSException if the JMS provider fails to create this message due
     *                 to some internal error.
     */
    public ObjectMessage createObjectMessage() throws JMSException {
        ActiveMQObjectMessage message = new ActiveMQObjectMessage();
        configureMessage(message);
        return message;
    }
View Full Code Here

     * @return an ActiveMQObjectMessage
     * @throws JMSException if the JMS provider fails to create this message due
     *                 to some internal error.
     */
    public ObjectMessage createObjectMessage(Serializable object) throws JMSException {
        ActiveMQObjectMessage message = new ActiveMQObjectMessage();
        configureMessage(message);
        message.setObject(object);
        return message;
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.ActiveMQObjectMessage

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.