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.manager.ResponseDispatcher.java

public ResponseDispatcher(InitialContext initConn, TopicConnectionFactory connectionFact,
        HashMap<Object, ConsumerProfile> requestMap, LearnerAssessmentManager learnerAssessmentManager) {

    ResponseDispatcher.requestMap = requestMap;
    ResponseDispatcher.initConn = initConn;
    ResponseDispatcher.lam = learnerAssessmentManager;
    try {//  w  ww. j a  v a 2s.c  o m
        connection = connectionFact.createTopicConnection();
        publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    } catch (JMSException e) {
        e.printStackTrace();
    }
}

From source file:TransactedChat.java

/** Cleanup resources cleanly and exit. */
private void exit() {
    try {/*from  ww  w .j a v a  2  s  .  c o  m*/
        publishSession.rollback(); // Rollback any uncommitted messages.
        connect.close();
    } catch (javax.jms.JMSException jmse) {
        jmse.printStackTrace();
    }

    System.exit(0);
}

From source file:com.provenance.cloudprovenance.eventhandler.service.EventProducer.java

public String sendToQueue(final String eventTypeDestination, final String resourceElements) {

    String policyResponseMsg = null;
    final String IGNORE_RECEIVE_QUEUE = "traceabilityQueue";

    jmsTemplate.send(eventTypeDestination, new MessageCreator() {

        public Message createMessage(Session session) throws JMSException {
            TextMessage message = session.createTextMessage(resourceElements);
            return message;
        }//from   ww  w .  j a  v a2s  .c o  m
    });

    logger.info("Message sent: " + resourceElements);

    if (!(eventTypeDestination.equals(IGNORE_RECEIVE_QUEUE))) {

        logger.info("waiting for response message from queue: " + responsePolicyQueueName);
        jmsTemplate.setReceiveTimeout(5000);
        Message message = jmsTemplate.receive(responsePolicyQueueName);

        if (message instanceof TextMessage) {
            TextMessage textMessage = (TextMessage) message;
            try {
                policyResponseMsg = textMessage.getText();

                logger.info("Message received: " + policyResponseMsg);
                return policyResponseMsg;

            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
        // it is a traceability event, i.e asynchronized
    } else if (eventTypeDestination.equals(IGNORE_RECEIVE_QUEUE)) {
        // need to return the policy id

        // if a response is needed from the store record (i.e synchronized)
        if (traceabilityStoreStorageAck) {
            // wait for a response;

            logger.info(
                    "waiting for a traceability response message from queue: " + responseTraceabilityQueueName);
            jmsTemplate.setReceiveTimeout(5000);
            Message message = jmsTemplate.receive(responseTraceabilityQueueName);

            if (message instanceof TextMessage) {
                TextMessage textMessage = (TextMessage) message;
                try {
                    String traceabilityResponseMsg = textMessage.getText();

                    logger.info("Message received, Id : " + traceabilityResponseMsg);
                    return traceabilityResponseMsg;

                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }
        }
        return "traceability stored successfully";

    }
    // did not recognise the message
    return null;
}

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

public void init(TopicConnectionFactory connectionFact, InitialContext initConn) {
    try {/*from  w ww  .j  a v a2 s . c om*/
        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 reading topic ");
        connectionTopic = (Topic) initConn.lookup(topic);
        tSub = subscribeSession.createSubscriber(connectionTopic, null, true);
        DebugMessages.ok();

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

        DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(),
                "Reading knowledge base ");
        kbase = readKnowledgeBase();
        ksession = kbase.newStatefulKnowledgeSession();
        ksession.setGlobal("EVENTS EntryPoint", eventStream);
        eventStream = ksession.getWorkingMemoryEntryPoint("DEFAULT");
        cepRuleManager = new DroolsRulesManager(kbuilder, kbase, ksession);
        DebugMessages.ok();

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

From source file:de.adorsys.jmspojo.JMSServiceAdapterFactoryTest.java

@Before
public void setup() throws Exception {
    broker = new BrokerService();
    broker.setPersistent(false);/*from  w w w.ja  v a  2 s  .c  o m*/

    // configure the broker
    broker.addConnector("vm://test");
    broker.setBrokerName("test");
    broker.setUseShutdownHook(false);

    broker.start();

    cf = new ActiveMQConnectionFactory("vm://localhost?create=false");
    qc = cf.createQueueConnection();
    QueueSession createQueueSession = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    defaultQueue = createQueueSession.createQueue("TestQueue");
    createQueueSession.createReceiver(defaultQueue).setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            try {
                boolean sendTimeout = message.getBooleanProperty("timeout");
                if (!sendTimeout) {
                    JMSJavaFutureAdapter<PingMessage> jmsSender = new JMSJavaFutureAdapter<PingMessage>(
                            OBJECT_MAPPER, cf, null, JMS_TIMEOUT);
                    jmsSender.send(message.getJMSReplyTo(), null, ((TextMessage) message).getText());
                }
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    });

    dedicatedQueue = createQueueSession.createQueue("DedicatedQueue");
    createQueueSession.createReceiver(dedicatedQueue).setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            try {
                JMSJavaFutureAdapter<PingMessage> jmsSender = new JMSJavaFutureAdapter<PingMessage>(
                        OBJECT_MAPPER, cf, null, JMS_TIMEOUT);
                PingMessage data = new PingMessage();
                data.setPing("dedicted response");
                jmsSender.send(message.getJMSReplyTo(), null, data);
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    });
    qc.start();

    JMSServiceAdapterFactory jmsServiceStubFactory = new JMSServiceAdapterFactory(OBJECT_MAPPER, cf,
            defaultQueue, JMS_TIMEOUT);
    service = jmsServiceStubFactory.generateJMSServiceProxy(JMSSampleService.class);

}

From source file:org.wso2.andes.systest.TestingBaseCase.java

public void onException(JMSException e) {
    _connectionException = e;

    e.printStackTrace();

    _disconnectionLatch.countDown();
}

From source file:eu.learnpad.simulator.mon.impl.ComplexEventProcessorImpl.java

public void run() {
    DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Starting connection ");
    try {//w ww.j ava2  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) {
        ksession.fireUntilHalt();
        //} 
    } catch (JMSException e) {
        e.printStackTrace();
    }
}

From source file:org.logicblaze.lingo.jms.JmsClient.java

public void close() {
    try {/*  www . j a v  a 2 s .  co  m*/
        if (consumer != null) {
            consumer.close();
        }
        if (producer != null) {
            producer.close();
        }
    } catch (JMSException e) {
        e.printStackTrace();
    } finally {
        consumer = null;
        producer = null;
    }
}

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

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

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

private void sendMessage(TextMessage msg) {
    try {/*from   ww  w .  ja  va  2  s .c  o m*/
        if (msg != null) {
            //System.out.println(this.getClass().getSimpleName() + ": send " + msg.getText());
            //DebugMessages.line();
            tPub.publish(msg);
        }
    } catch (JMSException e) {
        e.printStackTrace();
    }
}