Package org.apache.geronimo.jms.test.mdb.to

Examples of org.apache.geronimo.jms.test.mdb.to.SimpleTransferObject


            prod = sess.createProducer(destination);
            consumer = sess.createConsumer(destination);
            conn.start();

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                ut.begin();
                try {
                    prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                } finally {
                    ut.commit();
                }
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, destination, logger);
                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received first time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.rollback();
                }

                ut.begin();
                try {
                    received = consumer.receive(2000);
                    if (received == null) throw new JMSException("Not received second time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.commit();
                }

            }
View Full Code Here


            prod = sess.createProducer(destination);
            consumer = sess.createConsumer(destination);
            conn.start();

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                ut.begin();
                try {
                    prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                } finally {
                    ut.commit();
                }
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, destination, logger);
                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received first time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.rollback();
                }

                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received second time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.commit();
                }

            }
View Full Code Here

            sess = conn.createSession(true, Session.SESSION_TRANSACTED);
            prod = sess.createProducer(jmsRequestQueue);
            conn.start();

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setJMSReplyTo(jmsResponseQueue);
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, jmsRequestQueue, logger);
                MessageReceiver.browse("After send", sess, jmsResponseQueue, logger);
            }
View Full Code Here

            MessageReceiver.browse("Before receive", sess, jmsRequestQueue, logger);
            MessageReceiver.browse("Before receive", sess, jmsResponseQueue, logger);
            Message message = consumer.receive(1000);
            if (message != null) {
                ObjectMessage om = (ObjectMessage) message;
                SimpleTransferObject sto = (SimpleTransferObject) om.getObject();
                logger.info("Received message with name " + sto.getName() + sto.getId());
                return sto.getId();
            }
            return null;
        } catch (JMSException e) {
            logger.error("Bad news! Sending failed due to exception: " + e.getMessage());
            return null;
View Full Code Here

            s2 = c2.createSession(true, Session.SESSION_TRANSACTED);
            prod = sess.createProducer(destination);
            consumer = sess.createConsumer(destination);

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                ut.begin();
                try {
                    prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                } finally {
                    ut.commit();
                }
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, destination, logger);
                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received first time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.rollback();
                }

                ut.begin();
                try {
                    received = consumer.receive(2000);
                    if (received == null) throw new JMSException("Not received second time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.commit();
                }

            }
View Full Code Here

            prod = sess.createProducer(destination);
            consumer = sess.createConsumer(destination);
            conn.start();

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                ut.begin();
                try {
                    prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                } finally {
                    ut.commit();
                }
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, destination, logger);
                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received first time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.rollback();
                }

                ut.begin();
                try {
                    received = consumer.receive(1000);
                    if (received == null) throw new JMSException("Not received second time");
                    if (!to.equals(((ObjectMessage)received).getObject())) throw new JMSException("Wrong object inside: " + ((ObjectMessage)received).getObject());
                } finally {
                    ut.commit();
                }

            }
View Full Code Here

        if (obj == null) {
            throw new ProcessingException("Object received in message is null");
        } else if (!SimpleTransferObject.class.isInstance(obj)) {
            throw new ProcessingException(MessageFormat.format("Invalid class of object {0} included in received message", obj.getClass()));
        } else {
            SimpleTransferObject to = (SimpleTransferObject) obj;
            to.markProcessed();
            return to;
        }
    }
View Full Code Here

            conn = this.connFactory.createConnection();
            sess = conn.createSession(true, Session.SESSION_TRANSACTED);
            prod = sess.createProducer(jmsRequestQueue);

            for (int i = 0; i < counter; ++i) {
                SimpleTransferObject to = new SimpleTransferObject(requestName, i);

                ObjectMessage msg = sess.createObjectMessage();
                msg.setJMSReplyTo(jmsResponseQueue);
                msg.setObject(to);

                logger.info("Sending message with name " + to.getName());
                prod.send(msg, Message.DEFAULT_DELIVERY_MODE, priority, Message.DEFAULT_TIME_TO_LIVE);
                logger.info("Message sent.");
                MessageReceiver.browse("After send", sess, jmsRequestQueue, logger);
                MessageReceiver.browse("After send", sess, jmsResponseQueue, logger);
            }
View Full Code Here

            MessageReceiver.browse("Before receive", sess, jmsRequestQueue, logger);
            MessageReceiver.browse("Before receive", sess, jmsResponseQueue, logger);
            Message message = consumer.receive(1000);
            if (message != null) {
                ObjectMessage om = (ObjectMessage) message;
                SimpleTransferObject sto = (SimpleTransferObject) om.getObject();
                logger.info("Received message with name " + sto.getName() + sto.getId());
                return sto.getId();
            }
            return null;
        } catch (JMSException e) {
            logger.error("Bad news! Sending failed due to exception: " + e.getMessage());
            return null;
View Full Code Here

TOP

Related Classes of org.apache.geronimo.jms.test.mdb.to.SimpleTransferObject

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.