Package javax.jms

Examples of javax.jms.ObjectMessage


 
  @TransactionAttribute(TransactionAttributeType.REQUIRED
  public void onMessage(Message message) {
    try {
      System.out.println("Przetwarzam wiadomosc "+new Date());
      ObjectMessage objectMessage = (ObjectMessage) message;
      HashMap<String, String> mapa = (HashMap<String, String>) objectMessage
          .getObject();
      String tytul = mapa.get("tytul").toString();
      String adres = mapa.get("adres").toString();
      String tresc = mapa.get("tresc").toString();
      System.out.println(tytul);
View Full Code Here


        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(broker.getContainer().getName() + ": broadcasting info for " + event);
        }
        Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        try {
            ObjectMessage msg = broadcastSession.createObjectMessage(event);
            Topic broadcastTopic = broadcastSession.createTopic(broadcastDestinationName);
            MessageProducer topicProducer = broadcastSession.createProducer(broadcastTopic);
            topicProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
            topicProducer.send(msg);
        } finally {
View Full Code Here

            }
           
            Session inboundSession = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
            try {
                Queue queue = inboundSession.createQueue(destination);
                ObjectMessage msg = inboundSession.createObjectMessage(me);
                // Set message priority.
                Integer priority = (Integer) me.getProperty(JbiConstants.MESSAGE_PRIORITY);
                if (null != priority) {
                    msg.setJMSPriority(priority);
                }
                MessageProducer queueProducer = inboundSession.createProducer(queue);
                queueProducer.send(msg);
            } finally {
                inboundSession.close();
View Full Code Here

     * @param message
     */
    public void onMessage(final Message message) {
        try {
            if (message != null && started.get()) {
                ObjectMessage objMsg = (ObjectMessage) message;
                final MessageExchangeImpl me = (MessageExchangeImpl) objMsg.getObject();
                // Dispatch the message in another thread so as to free the jms
                // session
                // else if a component do a sendSync into the jms flow, the
                // whole
                // flow is deadlocked
View Full Code Here

     * @param message
     */
    public void onMessage(Message message) {
        try {
            if (message != null && started.get()) {
                ObjectMessage objMsg = (ObjectMessage) message;
                final MessageExchangeImpl me = (MessageExchangeImpl) objMsg.getObject();
                // Hack for redelivery: AMQ is too optimized and the object is
                // the same upon redelivery
                // so that there are side effect (the exchange state may have
                // been modified)
                // See http://jira.activemq.org/jira/browse/AMQ-519
View Full Code Here

        } else {
            connection = managedConnectionFactory.createConnection();
        }
        try {
            Session session = connection.createSession(transacted, transacted ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
            ObjectMessage msg = session.createObjectMessage(object);
            MessageProducer producer = session.createProducer(dest);
            producer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
            producer.send(msg);
        } finally {
            connection.close();
View Full Code Here

     * @return the body, can be <tt>null</tt>
     */
    public Object extractBodyFromJms(Exchange exchange, Message message) {
        try {
            if (message instanceof ObjectMessage) {
                ObjectMessage objectMessage = (ObjectMessage)message;
                return objectMessage.getObject();
            } else if (message instanceof TextMessage) {
                TextMessage textMessage = (TextMessage)message;
                return textMessage.getText();
            } else if (message instanceof MapMessage) {
                return createMapFromMapMessage((MapMessage)message);
View Full Code Here

        endpoint.expectedMessageCount(1);

        jmsTemplate.setPubSubDomain(false);
        jmsTemplate.send("test.object", new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                ObjectMessage msg = session.createObjectMessage();

                MyUser user = new MyUser();
                user.setName("Claus");
                msg.setObject(user);

                return msg;
            }
        });
View Full Code Here

            }
            dataOut.close();
            return NIOConverter.toByteBuffer(bytesOut.toByteArray());
        }
        if (message instanceof ObjectMessage) {
            ObjectMessage objMessage = (ObjectMessage)message;
            Object object = objMessage.getObject();
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
            objectOut.writeObject(object);
            objectOut.close();
            return NIOConverter.toByteBuffer(bytesOut.toByteArray());
View Full Code Here

    }

    protected Message createObjectJMSMessage(Session session, Object o) {
        try {

            ObjectMessage message = session.createObjectMessage(); // default
            message.setObject((Serializable)o);
            return message;

        } catch (JMSException e) {
            throw new JMSBindingException(e);
        }
View Full Code Here

TOP

Related Classes of javax.jms.ObjectMessage

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.