Example usage for javax.jms JMSException printStackTrace

List of usage examples for javax.jms JMSException printStackTrace

Introduction

In this page you can find the example usage for javax.jms JMSException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:it.cnr.isti.labse.glimpse.manager.GlimpseManager.java

public void setupConnection(TopicConnectionFactory connectionFact, InitialContext initConn) {
    try {/*from   w w w  .j ava2 s  .c  o  m*/
        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating connection object ");
        connection = connectionFact.createTopicConnection();
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating public session object ");
        publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating subscribe object");
        subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Setting up destination topic ");
        connectionTopic = (Topic) initConn.lookup(serviceTopic);
        tPub = publishSession.createPublisher(connectionTopic);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Setting up reading topic ");
        tSub = subscribeSession.createSubscriber(connectionTopic, "DESTINATION = 'monitor'", true);
        tSub.setMessageListener(this);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating response dispatcher ");
        responder = new ResponseDispatcher(initConn, connectionFact, requestMap);
        DebugMessages.ok();

    } catch (JMSException e) {
        e.printStackTrace();
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

From source file:Vendor.java

public void onMessage(Message message) {
    if (!(message instanceof MapMessage)) {
        synchronized (supplierLock) {
            numSuppliers--;//from  w w  w  .  ja va  2s . c  o m
            supplierLock.notifyAll();
        }
        try {
            asyncSession.commit();
            return;
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

    int orderNumber = -1;
    try {
        MapMessage componentMessage = (MapMessage) message;

        orderNumber = componentMessage.getInt("VendorOrderNumber");
        Order order = Order.getOrder(orderNumber);
        order.processSubOrder(componentMessage);
        asyncSession.commit();

        if (!"Pending".equals(order.getStatus())) {
            System.out.println("Vendor: Completed processing for order " + orderNumber);

            MessageProducer replyProducer = asyncSession.createProducer(order.getMessage().getJMSReplyTo());
            MapMessage replyMessage = asyncSession.createMapMessage();
            if ("Fulfilled".equals(order.getStatus())) {
                replyMessage.setBoolean("OrderAccepted", true);
                System.out.println("Vendor: sent " + order.quantity + " computer(s)");
            } else {
                replyMessage.setBoolean("OrderAccepted", false);
                System.out.println("Vendor: unable to send " + order.quantity + " computer(s)");
            }
            replyProducer.send(replyMessage);
            asyncSession.commit();
            System.out.println("Vender: committed transaction 2");
        }
    } catch (JMSException e) {
        e.printStackTrace();
    }
}

From source file:TransactedTalk.java

/** Cleanup resources and then exit. */
private void exit() {
    try {//www.  j a  va 2s .  co  m
        sendSession.rollback(); // Rollback any uncommitted messages.
        connect.close();
    } catch (javax.jms.JMSException jmse) {
        jmse.printStackTrace();
    }

    System.exit(0);
}

From source file:it.cnr.isti.labsedc.glimpse.impl.ComplexEventProcessorImpl.java

@Override
public void onMessage(Message arg0) {

    ObjectMessage msg = (ObjectMessage) arg0;
    try {/*w w w  .ja  v a  2s.co m*/
        GlimpseBaseEvent<?> receivedEvent = (GlimpseBaseEvent<?>) msg.getObject();
        if (eventStream != null && receivedEvent != null) {
            try {
                eventStream.insert(receivedEvent);
                if (receivedEvent instanceof GlimpseBaseEventChoreos<?>) {
                    DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                            "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: "
                                    + receivedEvent.getEventName() + "\n" + "timestamp: "
                                    + receivedEvent.getTimeStamp() + "\n" + "machineIP: "
                                    + ((GlimpseBaseEventChoreos<?>) receivedEvent).getMachineIP() + "\n"
                                    + "choreographySource: "
                                    + ((GlimpseBaseEventChoreos<?>) receivedEvent).getChoreographySource());
                } else if (receivedEvent instanceof GlimpseBaseEventBPMN<?>) {
                    DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                            "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: "
                                    + receivedEvent.getEventName() + "\n" + "timestamp: "
                                    + receivedEvent.getTimeStamp() + "\n" + "sessionID: "
                                    + ((GlimpseBaseEventBPMN<?>) receivedEvent).getSessionID() + "\n"
                                    + "assigneeID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getAssigneeID()
                                    + "\n" + "roleID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getRoleID()
                                    + "\n" + "taskID: " + ((GlimpseBaseEventBPMN<?>) receivedEvent).getTaskID()
                                    + "\n" + "subProcessID: "
                                    + ((GlimpseBaseEventBPMN<?>) receivedEvent).getSubProcessID() + "\n"
                                    + "desideredCompletionTime: "
                                    + ((GlimpseBaseEventBPMN<?>) receivedEvent).getDesideredCompletionTime());
                } else {
                    DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                            "receives:\n" + "eventData: " + receivedEvent.getEventData() + "\n" + "eventName: "
                                    + receivedEvent.getEventName() + "\n" + "timestamp: "
                                    + receivedEvent.getTimeStamp());
                }
                DebugMessages.line();
            } catch (org.drools.RuntimeDroolsException droolsCrashException) {
                DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                        droolsCrashException.getMessage());
                new UnknownMethodCallRuleException();
            }
        }
    } catch (JMSException e) {
        e.printStackTrace();
    } catch (ClassCastException ex) {
        DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), ex.getMessage());
    }
}

From source file:it.cnr.isti.labsedc.glimpse.manager.GlimpseManager.java

public void onMessage(Message arg0) {

    TextMessage msg = null;/*from   w  w  w  .j  a va  2  s  .  c  o m*/
    try {
        msg = (TextMessage) arg0;
        DebugMessages.line();
        DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "receive " + msg.getText());
        DebugMessages.line();
        String XMLRule = msg.getText();
        String sender = msg.getStringProperty("SENDER");

        ComplexEventRuleActionListDocument ruleDoc;
        ruleDoc = ComplexEventRuleActionListDocument.Factory.parse(XMLRule);
        ComplexEventRuleActionType rules = ruleDoc.getComplexEventRuleActionList();

        //the topic where the listener will give analysis results
        answerTopic = "answerTopic" + "#" + this.getName() + "#" + System.nanoTime();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Create answerTopic");
        connectionTopic = publishSession.createTopic(answerTopic);
        //tPub = publishSession.createPublisher(connectionTopic);
        DebugMessages.ok();

        DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Setting up ComplexEventProcessor with new rule.");
        try {
            Object[] loadedKnowledgePackage = rulesManagerOne.loadRules(rules);
            //inserisco la coppia chiave valore dove la chiave  il KnowledgePackage
            //caricato, generato da DroolsRulesManager con la loadRules
            //e il valore  l'enabler che l'ha inviata
            //(il KnowledgePackage array dovrebbe avere sempre dimensione 1 essendo creato ad ogni loadrules)
            for (int i = 0; i < loadedKnowledgePackage.length; i++) {
                KnowledgePackageImp singleKnowlPack = (KnowledgePackageImp) loadedKnowledgePackage[i];
                Rule[] singleRuleContainer = new Rule[singleKnowlPack.getRules().size()];
                singleRuleContainer = singleKnowlPack.getRules().toArray(singleRuleContainer);

                for (int j = 0; j < singleRuleContainer.length; j++) {
                    requestMap.put(singleRuleContainer[j].getName(), new ConsumerProfile(sender, answerTopic));
                }
            }
            DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                    "KnowledgeBase packages loaded: " + rulesManagerOne.getLoadedKnowledgePackageCardinality());
            DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                    "Communicate the answerTopic to the requester");
            sendMessage(createMessage("AnswerTopic == " + answerTopic, sender));
            DebugMessages.ok();
        } catch (IncorrectRuleFormatException e) {
            sendMessage(createMessage("PROVIDED RULE CONTAINS ERRORS", sender));
        }
    } catch (NullPointerException asd) {
        try {
            sendMessage(createMessage("PROVIDED RULE IS NULL, PLEASE PROVIDE A VALID RULE",
                    msg.getStringProperty("SENDER")));
        } catch (JMSException e) {
            e.printStackTrace();
        }
    } catch (XmlException e) {
        try {
            sendMessage(createMessage("PROVIDED XML CONTAINS ERRORS", msg.getStringProperty("SENDER")));
        } catch (JMSException e1) {
            e1.printStackTrace();
        }
    } catch (JMSException ee) {
        ee.printStackTrace();
    }
    DebugMessages.line();
}

From source file:org.audit4j.core.AsyncAuditEngine.java

/**
 * Initialize if needed.//from  ww w.ja v a2 s  .com
 */
private synchronized void initializeIfNeeded() {
    try {
        if (session == null) {
            // Create a ConnectionFactory
            connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
            connection = connectionFactory.createConnection();
            connection.start();
            connection.setExceptionListener(this);
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            destination = session.createQueue(queueName);
        } else {
            log.trace("messageListener already defined");
        }

    } catch (final JMSException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.apache.activemq.network.MQTTNetworkOfBrokersFailoverTest.java

private CountDownLatch listenForConsumersOn(BrokerService broker) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);

    URI brokerUri = broker.getVmConnectorURI();

    final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerUri.toASCIIString());
    final Connection connection = cf.createConnection();
    connection.start();/*from  ww  w  .java2  s .c om*/
    final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination dest = session
            .createTopic("ActiveMQ.Advisory.Consumer.Queue.Consumer.foo:AT_LEAST_ONCE.VirtualTopic.foo.bar");
    MessageConsumer consumer = session.createConsumer(dest);
    consumer.setMessageListener(new MessageListener() {
        @Override
        public void onMessage(Message message) {
            latch.countDown();
            // shutdown this connection
            Dispatch.getGlobalQueue().execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        session.close();
                        connection.close();
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    });

    return latch;
}

From source file:eu.learnpad.simulator.mon.manager.GlimpseManager.java

public void setupConnection(TopicConnectionFactory connectionFact, InitialContext initConn) {
    try {//www  .  j a va 2 s .c  o m
        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating connection object ");
        connection = connectionFact.createTopicConnection();
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating public session object ");
        publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating subscribe object");
        subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Setting up destination topic ");
        connectionTopic = (Topic) initConn.lookup(serviceTopic);
        tPub = publishSession.createPublisher(connectionTopic);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Setting up reading topic ");
        tSub = subscribeSession.createSubscriber(connectionTopic, "DESTINATION = 'monitor'", true);
        tSub.setMessageListener(this);
        DebugMessages.ok();

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Creating response dispatcher ");
        responder = new ResponseDispatcher(initConn, connectionFact, requestMap, learnerAssessmentManager);
        if (responder != null)
            DebugMessages.ok();

    } catch (JMSException e) {
        e.printStackTrace();
    } catch (NamingException e) {
        e.printStackTrace();
    }
}

From source file:Replier.java

/**
 * Handle the message.//from   w w w  .jav a2s .  c om
 * (as specified in the javax.jms.MessageListener interface).
 *
 * IMPORTANT NOTES:
 * (1)We must follow the design paradigm for JMS
 *    synchronous requests.  That is, we must:
 *     - get the message
 *     - look for the header specifying JMSReplyTo
 *     - send a reply to the queue specified there.
 *    Failing to follow these steps might leave the originator
 *    of the request waiting forever.
 * (2)Unlike the 'Talk' sample and others using an asynchronous
 *    message listener, it is possible here to use ONLY
 *    ONE SESSION because the messages being sent are sent from
 *    the same thread of control handling message delivery. For
 *    more information see the JMS spec v1.0.2 section 4.4.6.
 *
 * OPTIONAL BEHAVIOR: The following actions taken by the
 * message handler represent good programming style, but are
 * not required by the design paradigm for JMS requests.
 *   - set the JMSCorrelationID (tying the response back to
 *     the original request.
 *   - use transacted session "commit" so receipt of request
 *     won't happen without the reply being sent.
 *
 */
public void onMessage(javax.jms.Message aMessage) {
    try {
        // Cast the message as a text message.
        javax.jms.TextMessage textMessage = (javax.jms.TextMessage) aMessage;

        // This handler reads a single String from the
        // message and prints it to the standard output.
        try {
            String string = textMessage.getText();
            System.out.println("[Request] " + string);

            // Check for a ReplyTo Queue
            javax.jms.Queue replyQueue = (javax.jms.Queue) aMessage.getJMSReplyTo();
            if (replyQueue != null) {
                // Send the modified message back.
                javax.jms.TextMessage reply = session.createTextMessage();
                if (imode == UPPERCASE)
                    reply.setText("Uppercasing-" + string.toUpperCase());
                else
                    reply.setText("Lowercasing-" + string.toLowerCase());
                reply.setJMSCorrelationID(aMessage.getJMSMessageID());
                replier.send(replyQueue, reply);
                session.commit();
            }
        } catch (javax.jms.JMSException jmse) {
            jmse.printStackTrace();
        }
    } catch (java.lang.RuntimeException rte) {
        rte.printStackTrace();
    }
}

From source file:TransactedTalk.java

/**
 * Handle the message/*w  ww. j  a  va 2 s  .  co m*/
 * (as specified in the javax.jms.MessageListener interface).
 */
public void onMessage(javax.jms.Message aMessage) {
    try {
        // Cast the message as a text message.
        javax.jms.TextMessage textMessage = (javax.jms.TextMessage) aMessage;

        // This handler reads a single String from the
        // message and prints it to the standard output.
        try {
            String string = textMessage.getText();
            System.out.println(string);
        } catch (javax.jms.JMSException jmse) {
            jmse.printStackTrace();
        }
    } catch (java.lang.RuntimeException rte) {
        rte.printStackTrace();
    }
}