Example usage for javax.jms Session getClass

List of usage examples for javax.jms Session getClass

Introduction

In this page you can find the example usage for javax.jms Session getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:nl.nn.adapterframework.extensions.tibco.TibcoMessagingSource.java

public Destination lookupDestination(String destinationName) throws JmsException {
    Session session = null;
    try {//from ww w  . jav  a 2 s  .c  o  m
        session = createSession(false, Session.AUTO_ACKNOWLEDGE);
        log.debug("Session class [" + session.getClass().getName() + "]");
        Destination destination;

        /* create the destination */
        if (session instanceof TopicSession) {
            destination = ((TopicSession) session).createTopic(destinationName);
        } else {
            destination = ((QueueSession) session).createQueue(destinationName);
        }

        return destination;
    } catch (Exception e) {
        throw new JmsException("cannot create destination", e);
    } finally {
        releaseSession(session);
    }
}

From source file:nl.nn.adapterframework.jms.JMSFacade.java

public String send(Session session, Destination dest, String correlationId, String message, String messageType,
        long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException,
        Map properties) throws NamingException, JMSException, SenderException {
    TextMessage msg = createTextMessage(session, correlationId, message);
    MessageProducer mp;//from   www .j ava  2  s .co m
    try {
        if (useJms102()) {
            if ((session instanceof TopicSession) && (dest instanceof Topic)) {
                mp = getTopicPublisher((TopicSession) session, (Topic) dest);
            } else {
                if ((session instanceof QueueSession) && (dest instanceof Queue)) {
                    mp = getQueueSender((QueueSession) session, (Queue) dest);
                } else {
                    throw new SenderException(
                            "classes of Session [" + session.getClass().getName() + "] and Destination ["
                                    + dest.getClass().getName() + "] do not match (Queue vs Topic)");
                }
            }
        } else {
            mp = session.createProducer(dest);
        }
    } catch (InvalidDestinationException e) {
        if (ignoreInvalidDestinationException) {
            log.warn("queue [" + dest + "] doesn't exist");
            return null;
        } else {
            throw e;
        }
    }
    if (messageType != null) {
        msg.setJMSType(messageType);
    }
    if (deliveryMode > 0) {
        msg.setJMSDeliveryMode(deliveryMode);
        mp.setDeliveryMode(deliveryMode);
    }
    if (priority >= 0) {
        msg.setJMSPriority(priority);
        mp.setPriority(priority);
    }
    if (timeToLive > 0) {
        mp.setTimeToLive(timeToLive);
    }
    if (properties != null) {
        for (Iterator it = properties.keySet().iterator(); it.hasNext();) {
            String key = (String) it.next();
            Object value = properties.get(key);
            log.debug("setting property [" + name + "] to value [" + value + "]");
            msg.setObjectProperty(key, value);
        }
    }
    String result = send(mp, msg, ignoreInvalidDestinationException);
    mp.close();
    return result;
}

From source file:org.eclipse.kapua.broker.core.pool.JmsAssistantProducerWrapperFactory.java

/**
 * Check if the session is still active/*  www.  j a  v a 2  s. co  m*/
 */
@Override
public boolean validateObject(PooledObject<JmsAssistantProducerWrapper> p) {
    Session session = p.getObject().session;
    if (session instanceof ActiveMQSession) {
        return !((ActiveMQSession) session).isClosed();
    } else {
        s_logger.warn("Wrong session object type {}", session.getClass());
        return true;
    }
}