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:eu.learnpad.simulator.mon.impl.ComplexEventProcessorImpl.java

@Override
public void onMessage(Message arg0) {

    ObjectMessage msg = (ObjectMessage) arg0;
    try {/*  w w  w .  jav a  2s . co m*/
        GlimpseBaseEvent<?> receivedEvent = (GlimpseBaseEvent<?>) msg.getObject();
        if (eventStream != null && receivedEvent != null) {
            try {
                eventStream.insert(receivedEvent);

                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" + "event: "
                                    + ((GlimpseBaseEventBPMN<?>) receivedEvent).getEvent());
                } 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.impl.ComplexEventProcessorImpl.java

public void run() {
    DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Starting connection ");
    try {/*from ww  w.  j av a2 s  .c o m*/
        if (connection == null) {
            System.out.println(
                    "Unable to connect to ActiveMQ instance or connection parameters wrong.\nPlease check and restart GLIMPSE.");
            System.exit(0);
        }
        connection.start();
        DebugMessages.ok();
        tSub.setMessageListener(this);
        DebugMessages.line();
        while (this.getState() == State.RUNNABLE) {
            Thread.sleep(20);
            ksession.fireAllRules();
        }
    } catch (JMSException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

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

private void sendMessage(TextMessage msg) {
    try {// w w  w . j ava2 s .c  o m
        if (msg != null) {
            tPub.publish(msg);
        }
    } catch (JMSException e) {
        e.printStackTrace();
    }
}

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

public void run() {
    DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Starting connection ");
    try {//from   w  w  w.ja  v a2  s .com
        connection.start();
    } catch (JMSException e) {
        e.printStackTrace();
    }
    DebugMessages.ok();
    DebugMessages.line();
    System.out.println(this.getClass().getSimpleName() + ": is now ready to accept incoming requests ");
    DebugMessages.line();
}

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

private TextMessage createMessage(String msg, String sender) {
    try {/*from   ww  w  . j  a v a 2  s.com*/
        TextMessage sendMessage = publishSession.createTextMessage();
        sendMessage.setText(msg);
        sendMessage.setStringProperty("DESTINATION", sender);
        sendMessage.setBooleanProperty("ISASCORE", false);
        return sendMessage;
    } catch (JMSException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Replier.java

/** Cleanup resources cleanly and exit. */
private void exit() {
    try {/*from w  w  w  . ja  va 2  s  . c  o m*/
        connect.close();
    } catch (javax.jms.JMSException jmse) {
        jmse.printStackTrace();
    }

    System.exit(0);
}

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

/**
 * Listen./*from   w  w w.j  a  v a2  s . com*/
 */
public void listen() {
    try {
        final MessageConsumer consumer = session.createConsumer(destination);

        final MessageListener listener = new MessageListener() {

            @Override
            public void onMessage(final Message message) {
                try {
                    final ObjectMessage objectMessage = (ObjectMessage) message;
                    final Object object = objectMessage.getObject();
                    if (object instanceof AnnotationAuditEvent) {
                        AsynchronousAnnotationProcessor processor = AsynchronousAnnotationProcessor
                                .getInstance();
                        processor.process((AnnotationAuditEvent) object);
                    } else if (object instanceof AsyncCallAuditDto) {

                    }
                } catch (final JMSException e) {
                    e.printStackTrace();
                }
                try {
                    message.acknowledge();
                } catch (final JMSException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println("Received Message");
            }
        };

        consumer.setMessageListener(listener);

    } catch (final Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }
}

From source file:TopicReplier.java

/**
 * Handle the message./*www . j  av  a2s  .co  m*/
 * (as specified in the javax.jms.MessageListener interface).
 *
 * IMPORTANT NOTE: 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 topic specified there.
 * Failing to follow these steps might leave the originator
 * of the request waiting forever.
 *
 * 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 topic
            javax.jms.Topic replyTopic = (javax.jms.Topic) aMessage.getJMSReplyTo();
            if (replyTopic != null) {
                // Send the modified message back.
                javax.jms.TextMessage reply = session.createTextMessage();
                if (imode == UPPERCASE)
                    reply.setText("Transformed " + string + " to all uppercase: " + string.toUpperCase());
                else
                    reply.setText("Transformed " + string + " to all lowercase " + string.toLowerCase());
                reply.setJMSCorrelationID(aMessage.getJMSMessageID());
                replier.send(replyTopic, reply);
                session.commit();
            }
        } catch (javax.jms.JMSException jmse) {
            jmse.printStackTrace();
        }
    } catch (java.lang.RuntimeException rte) {
        rte.printStackTrace();
    }
}

From source file:Talk.java

/**
 * Handle the message//from   ww  w  .j a  v a 2  s.  c  om
 * (as specified in the javax.jms.MessageListener interface).
 */
public void onMessage(javax.jms.Message aMessage) {
    try {
        // Cast the message as a text message.
        // Otherwise report that invalid message arrived.
        if (aMessage instanceof javax.jms.TextMessage) {
            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();
            }
        } else {
            System.out.println("Warning: A message was discarded because it could not be processed "
                    + "as a javax.jms.TextMessage.");
        }

    } catch (java.lang.RuntimeException rte) {
        rte.printStackTrace();
    }
}

From source file:org.nuxeo.ecm.core.jms.JMSEventListener.java

/**
 * Core event notification./*from   w  w  w .j  a  v  a  2s  . co m*/
 * <p>
 * Gets core events and transmits them to a JMS as a DocumentMessage.
 *
 * @param coreEvent instance fired at core layer
 */
@Override
public void handleEvent(CoreEvent coreEvent) {
    //TODO: this should be refactored after operation are integrated into core
    Operation<?> cmd = Operation.getCurrent();
    if (cmd != null) { // we ignore events inside a command
        return;
    }

    Map<String, ?> info = coreEvent.getInfo();
    // avoid to send blocked events
    if (info != null && coreEvent.getInfo().get(BLOCK_JMS_PRODUCING) != null
            && (Boolean) coreEvent.getInfo().get(BLOCK_JMS_PRODUCING)) {
        log.debug("JMS forwarding disabled for event " + coreEvent.getEventId());
        return;
    }

    // Is it a document saved session event ? - this should be refactored to use commands
    boolean flush = DocumentEventTypes.SESSION_SAVED.equals(coreEvent.getEventId());

    if (!flush && !(coreEvent.getSource() instanceof DocumentModel)) {
        log.debug("Not a document centric message. Avoid fwd.");
        //sendEventToJMS(coreEvent);
    } else {
        DocumentModel source = (DocumentModel) coreEvent.getSource();
        if (source != null && source.getContextData(BLOCK_JMS_PRODUCING) != null
                && (Boolean) source.getContextData(BLOCK_JMS_PRODUCING)) {
            log.debug("JMS forwarding disabled for events on doc " + source.getRef().toString()
                    + "... skipping.");
            return;
        }
        if (flush) {
            String sid = (String) coreEvent.getInfo().get(CoreEventConstants.SESSION_ID);
            List<CoreEvent> stack = getStackForSessionId(sid);
            if (stack == null) {
                // this should never happend
                log.error("Received a Save event without known SessionID");
            } else {
                log.debug("Flushing event stack for session " + sid);

                // Here, variable only used by logging. Since this is not
                // synchronized here it might be not correct.
                int nbEvt = stack.size();
                long t = System.currentTimeMillis();

                try {
                    sendEventToJMS(stack);
                    /*
                     * for (CoreEvent stackedEvent : stack) {
                     * sendEventToJMS(stackedEvent); }
                     */
                    log.debug(nbEvt + " events flushed in " + (System.currentTimeMillis() - t) + " ms");
                } catch (JMSException e) {
                    e.printStackTrace();
                } finally {
                    synchronized (eventsStack) {
                        eventsStack.remove(sid);
                    }
                }
            }
        } else {
            log.debug("Document centric event. Let's stack it until session is saved");
            stackEvent(coreEvent);
        }
    }
}